From 3de8cf929b4e4e710221c9fa9b028096776859c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:05:33 +0000 Subject: [PATCH] deploy: 0d882f8907a77795c879dc2e2acb022a98c146b0 --- 404.html | 4 ++-- assets/js/{1c4ae0dc.f844d960.js => 1c4ae0dc.b3c53158.js} | 2 +- assets/js/{1cd62bc7.ae7e9acf.js => 1cd62bc7.c610c713.js} | 2 +- assets/js/{32b584a3.97b27bd2.js => 32b584a3.ee6d4c10.js} | 2 +- assets/js/{b2f554cd.0cfabe3d.js => b2f554cd.505c317f.js} | 2 +- assets/js/{dd05a678.a0a4af3a.js => dd05a678.00795e33.js} | 2 +- assets/js/{main.7e1fbb86.js => main.e0c5ef23.js} | 4 ++-- ...1fbb86.js.LICENSE.txt => main.e0c5ef23.js.LICENSE.txt} | 0 ...{runtime~main.df429403.js => runtime~main.a549d6e8.js} | 2 +- blog/archive/index.html | 6 +++--- blog/atom.xml | 4 ++-- blog/index.html | 8 ++++---- blog/rss.xml | 4 ++-- blog/rust-python/index.html | 8 ++++---- docs/api/c-api/index.html | 4 ++-- docs/api/cli/index.html | 4 ++-- docs/api/dataflow-config/index.html | 4 ++-- docs/examples/index.html | 6 +++--- docs/footers/privacy-policy/index.html | 4 ++-- docs/guides/Debugging/logs/index.html | 4 ++-- docs/guides/Debugging/metrics/index.html | 4 ++-- docs/guides/Debugging/tracing/index.html | 4 ++-- docs/guides/Development/Arrow/index.html | 4 ++-- docs/guides/Development/Cuda/index.html | 4 ++-- docs/guides/Development/dynamic-node/index.html | 4 ++-- docs/guides/Development/hot-reload/index.html | 4 ++-- docs/guides/Installation/installing/index.html | 4 ++-- docs/guides/Installation/uninstalling/index.html | 4 ++-- docs/guides/Installation/updating/index.html | 4 ++-- docs/guides/dora-drives/carla/index.html | 4 ++-- docs/guides/dora-drives/control/index.html | 4 ++-- docs/guides/dora-drives/index.html | 4 ++-- docs/guides/dora-drives/installation/index.html | 4 ++-- docs/guides/dora-drives/obstacle_location/index.html | 4 ++-- docs/guides/dora-drives/planning/index.html | 4 ++-- docs/guides/dora-ros2-bridges/index.html | 4 ++-- docs/guides/getting-started/conversation_py/index.html | 4 ++-- docs/guides/getting-started/llm/index.html | 4 ++-- docs/guides/getting-started/webcam_plot/index.html | 4 ++-- docs/guides/getting-started/yolov8/index.html | 4 ++-- docs/guides/index.html | 4 ++-- docs/guides/support-matrix/index.html | 4 ++-- docs/nodes/index.html | 6 +++--- docs/nodes_operators/fot_op/index.html | 4 ++-- docs/nodes_operators/midas_op/index.html | 4 ++-- docs/nodes_operators/obstacle_location_op/index.html | 4 ++-- docs/nodes_operators/pid_control_op/index.html | 4 ++-- docs/nodes_operators/plot/index.html | 4 ++-- docs/nodes_operators/strong_sort_op/index.html | 4 ++-- docs/nodes_operators/webcam_op/index.html | 4 ++-- docs/nodes_operators/yolop_op/index.html | 4 ++-- docs/nodes_operators/yolov5_op/index.html | 4 ++-- docs/references/communication-layer/index.html | 4 ++-- docs/references/index.html | 4 ++-- docs/references/library-vs-framework/index.html | 4 ++-- docs/references/overview/index.html | 4 ++-- docs/references/state-management/index.html | 4 ++-- index.html | 4 ++-- installation-scripts/index.html | 4 ++-- search/index.html | 4 ++-- zh-CN/404.html | 4 ++-- .../js/{0ef6350b.1ce56390.js => 0ef6350b.497d8ec3.js} | 2 +- .../js/{1c4ae0dc.199b35f4.js => 1c4ae0dc.c5a8848b.js} | 2 +- .../js/{1cd62bc7.85a366fa.js => 1cd62bc7.33914947.js} | 2 +- .../js/{32b584a3.358999d3.js => 32b584a3.c68ec507.js} | 2 +- .../js/{50bc71d4.f378d3bf.js => 50bc71d4.fb07efd1.js} | 2 +- zh-CN/assets/js/{main.5b3f751b.js => main.d75a84d9.js} | 4 ++-- ...3f751b.js.LICENSE.txt => main.d75a84d9.js.LICENSE.txt} | 0 ...{runtime~main.440ad345.js => runtime~main.84a7929a.js} | 2 +- zh-CN/blog/archive/index.html | 6 +++--- zh-CN/blog/atom.xml | 4 ++-- zh-CN/blog/index.html | 8 ++++---- zh-CN/blog/rss.xml | 4 ++-- zh-CN/blog/rust-python/index.html | 8 ++++---- zh-CN/docs/api/c-api/index.html | 4 ++-- zh-CN/docs/api/cli/index.html | 4 ++-- zh-CN/docs/api/dataflow-config/index.html | 4 ++-- zh-CN/docs/examples/index.html | 6 +++--- zh-CN/docs/footers/privacy-policy/index.html | 4 ++-- zh-CN/docs/guides/Debugging/logs/index.html | 4 ++-- zh-CN/docs/guides/Debugging/metrics/index.html | 4 ++-- zh-CN/docs/guides/Debugging/tracing/index.html | 4 ++-- zh-CN/docs/guides/Development/Arrow/index.html | 4 ++-- zh-CN/docs/guides/Development/Cuda/index.html | 4 ++-- zh-CN/docs/guides/Development/dynamic-node/index.html | 4 ++-- zh-CN/docs/guides/Development/hot-reload/index.html | 4 ++-- zh-CN/docs/guides/Installation/installing/index.html | 4 ++-- zh-CN/docs/guides/Installation/uninstalling/index.html | 4 ++-- zh-CN/docs/guides/Installation/updating/index.html | 4 ++-- zh-CN/docs/guides/dora-drives/carla/index.html | 4 ++-- zh-CN/docs/guides/dora-drives/control/index.html | 4 ++-- zh-CN/docs/guides/dora-drives/index.html | 4 ++-- zh-CN/docs/guides/dora-drives/installation/index.html | 4 ++-- .../docs/guides/dora-drives/obstacle_location/index.html | 4 ++-- zh-CN/docs/guides/dora-drives/planning/index.html | 4 ++-- zh-CN/docs/guides/dora-ros2-bridges/index.html | 4 ++-- .../guides/getting-started/conversation_py/index.html | 4 ++-- zh-CN/docs/guides/getting-started/llm/index.html | 4 ++-- zh-CN/docs/guides/getting-started/webcam_plot/index.html | 4 ++-- zh-CN/docs/guides/getting-started/yolov8/index.html | 4 ++-- zh-CN/docs/guides/index.html | 4 ++-- zh-CN/docs/guides/support-matrix/index.html | 4 ++-- zh-CN/docs/nodes/index.html | 6 +++--- zh-CN/docs/nodes_operators/fot_op/index.html | 4 ++-- zh-CN/docs/nodes_operators/midas_op/index.html | 4 ++-- .../docs/nodes_operators/obstacle_location_op/index.html | 4 ++-- zh-CN/docs/nodes_operators/pid_control_op/index.html | 4 ++-- zh-CN/docs/nodes_operators/plot/index.html | 4 ++-- zh-CN/docs/nodes_operators/strong_sort_op/index.html | 4 ++-- zh-CN/docs/nodes_operators/webcam_op/index.html | 4 ++-- zh-CN/docs/nodes_operators/yolop_op/index.html | 4 ++-- zh-CN/docs/nodes_operators/yolov5_op/index.html | 4 ++-- zh-CN/docs/references/communication-layer/index.html | 4 ++-- zh-CN/docs/references/index.html | 4 ++-- zh-CN/docs/references/library-vs-framework/index.html | 4 ++-- zh-CN/docs/references/overview/index.html | 4 ++-- zh-CN/docs/references/state-management/index.html | 4 ++-- zh-CN/index.html | 4 ++-- zh-CN/installation-scripts/index.html | 4 ++-- zh-CN/search/index.html | 4 ++-- 120 files changed, 238 insertions(+), 238 deletions(-) rename assets/js/{1c4ae0dc.f844d960.js => 1c4ae0dc.b3c53158.js} (99%) rename assets/js/{1cd62bc7.ae7e9acf.js => 1cd62bc7.c610c713.js} (89%) rename assets/js/{32b584a3.97b27bd2.js => 32b584a3.ee6d4c10.js} (99%) rename assets/js/{b2f554cd.0cfabe3d.js => b2f554cd.505c317f.js} (99%) rename assets/js/{dd05a678.a0a4af3a.js => dd05a678.00795e33.js} (89%) rename assets/js/{main.7e1fbb86.js => main.e0c5ef23.js} (98%) rename assets/js/{main.7e1fbb86.js.LICENSE.txt => main.e0c5ef23.js.LICENSE.txt} (100%) rename assets/js/{runtime~main.df429403.js => runtime~main.a549d6e8.js} (96%) rename zh-CN/assets/js/{0ef6350b.1ce56390.js => 0ef6350b.497d8ec3.js} (89%) rename zh-CN/assets/js/{1c4ae0dc.199b35f4.js => 1c4ae0dc.c5a8848b.js} (99%) rename zh-CN/assets/js/{1cd62bc7.85a366fa.js => 1cd62bc7.33914947.js} (89%) rename zh-CN/assets/js/{32b584a3.358999d3.js => 32b584a3.c68ec507.js} (99%) rename zh-CN/assets/js/{50bc71d4.f378d3bf.js => 50bc71d4.fb07efd1.js} (99%) rename zh-CN/assets/js/{main.5b3f751b.js => main.d75a84d9.js} (99%) rename zh-CN/assets/js/{main.5b3f751b.js.LICENSE.txt => main.d75a84d9.js.LICENSE.txt} (100%) rename zh-CN/assets/js/{runtime~main.440ad345.js => runtime~main.84a7929a.js} (94%) diff --git a/404.html b/404.html index f87a9fb5..65b5c6a4 100644 --- a/404.html +++ b/404.html @@ -9,8 +9,8 @@ - - + +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

diff --git a/assets/js/1c4ae0dc.f844d960.js b/assets/js/1c4ae0dc.b3c53158.js similarity index 99% rename from assets/js/1c4ae0dc.f844d960.js rename to assets/js/1c4ae0dc.b3c53158.js index a79b9525..4a7ac3cb 100644 --- a/assets/js/1c4ae0dc.f844d960.js +++ b/assets/js/1c4ae0dc.b3c53158.js @@ -1 +1 @@ -"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[8902],{3321:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>o,toc:()=>c});var r=t(74848),a=t(28453);const s={authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},i=void 0,o={permalink:"/blog/rust-python",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/rust-python.md",source:"@site/blog/rust-python.md",title:"Rust-Python FFI",description:"Rust-Python FFI.",date:"2025-01-11T14:26:10.000Z",tags:[],readingTime:10.8,hasTruncateMarker:!1,authors:[{name:"Haixuan Xavier Tao",title:"Maintainer of dora-rs",url:"https://github.com/haixuantao",imageURL:"https://github.com/haixuantao.png",key:"haixuan"}],frontMatter:{authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},unlisted:!1},l={authorsImageUrls:[void 0]},c=[{value:"Foreign Function Interface",id:"foreign-function-interface",level:2},{value:"Interfacing Arrays",id:"interfacing-arrays",level:2},{value:"Implementation 1: Default",id:"implementation-1-default",level:3},{value:"> Calling create_list for a very large list like: value = [1] * 100_000_000 is going to return in 2.27s \ud83d\ude9c",id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",level:4},{value:"Implementation 2: PyBytes",id:"implementation-2-pybytes",level:3},{value:"> For the same list input, create_list_bytes returns in 78 milliseconds. That's 30x better \ud83d\udc0e",id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",level:4},{value:"Implementation 3: Apache Arrow",id:"implementation-3-apache-arrow",level:3},{value:"> Same list returns in 33 milliseconds . That's 2x better than PyBytes \ud83d\udc0e\ud83d\udc0e",id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",level:4},{value:"Debugging",id:"debugging",level:2},{value:".unwrap()",id:"unwrap",level:3},{value:"> Example error:",id:"-example-error",level:4},{value:"eyre",id:"eyre",level:3},{value:"> Same error as above but with eyre which gives a better looking error message:",id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",level:4},{value:"Python traceback with eyre",id:"python-traceback-with-eyre",level:3},{value:"> Example error with no custom traceback:",id:"-example-error-with-no-custom-traceback",level:4},{value:"> Better errors with custom traceback:",id:"-better-errors-with-custom-traceback",level:4},{value:"Memory management",id:"memory-management",level:2},{value:"> Calling this function will consume 440MB of memory. \ud83d\udc4e",id:"-calling-this-function-will-consume-440mb-of-memory--1",level:4},{value:"> Calling this function will consume 80MB of memory. :thumbsup:",id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",level:4},{value:"Race condition",id:"race-condition",level:2},{value:"> This threaded print was printed after 10.0s. \ud83d\ude22",id:"-this-threaded-print-was-printed-after-100s-cry",level:4},{value:"> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. \ud83d\ude04",id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",level:4},{value:"Tracing",id:"tracing",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:"Writing a rust library that is usable in multiple languages is not easy..."}),"\n",(0,r.jsxs)(n.p,{children:["This blogpost recollects things I have encountered while building ",(0,r.jsx)(n.a,{href:"https://github.com/webonnx/wonnx",children:"wonnx"})," and ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"}),". I am going to use Rust-Python FFI through ",(0,r.jsx)(n.code,{children:"pyo3"})," as an example. You can then extrapolate those issues to other languages FFI."]}),"\n",(0,r.jsx)(n.h2,{id:"foreign-function-interface",children:"Foreign Function Interface"}),"\n",(0,r.jsx)(n.p,{children:"A foreign function interface (FFI) is an interface used to share data from different languages."}),"\n",(0,r.jsxs)(n.p,{children:["By default, python might not know what a Rust ",(0,r.jsx)(n.code,{children:"u16"})," is, so an interface is needed to make the two languages communicate."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://hackmd.io/_uploads/S1qiK8hRh.png",alt:""})}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Image from ",(0,r.jsx)(n.a,{href:"https://hacks.mozilla.org/2019/08/webassembly-interface-types/",children:"WebAssembly Interface Types: Interoperate with All the Things!"})]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"Building interfaces is not easy. Most of the time, we have to use the C-ABI to build our FFI as it is the common denominator between languages."}),"\n",(0,r.jsx)(n.p,{children:"Thankfully, there are FFI libraries that create interfaces for us and we can just focus on the important stuff such as the logic, algorithm, and so on."}),"\n",(0,r.jsx)(n.p,{children:"However, those FFI libraries might have limitations. This is what we're going to discuss."}),"\n",(0,r.jsxs)(n.p,{children:["One example of such FFI library is ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})}),". ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})})," is one of the most used Rust-Python binding and creates FFIs for you. All we have to do is wrap our function with a ",(0,r.jsx)(n.code,{children:"#[pyfunction]"})," and that will make it usable in Python."]}),"\n",(0,r.jsx)(n.h2,{id:"interfacing-arrays",children:"Interfacing Arrays"}),"\n",(0,r.jsxs)(n.p,{children:["In this blog post, I'm going to build a toy Rust-Python project with ",(0,r.jsx)(n.code,{children:"pyo3"})," to illustrate the issues I have faced."]}),"\n",(0,r.jsxs)(n.p,{children:["You can try this blogpost at home by forking the ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi",children:"blogpost repository"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"If you want to start from scratch, you can create a new project with:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"mkdir blogpost_ffi\nmaturin init # pyo3\n"})}),"\n",(0,r.jsx)(n.p,{children:"The default project will looks like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"use pyo3::prelude::*;\n\n/// Formats the sum of two numbers as string.\n#[pyfunction]\nfn sum_as_string(a: usize, b: usize) -> PyResult {\n Ok((a + b).to_string())\n}\n\n/// A Python module implemented in Rust. The name of this function must match\n/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to\n/// import the module.\n#[pymodule]\nfn string_sum(_py: Python<'_>, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"We can call the function as follows:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'maturin develop\npython -c "import blogpost_ffi; print(blogpost_ffi.sum_as_string(1,1))"\n# Return: "2" \n'})}),"\n",(0,r.jsxs)(n.p,{children:["In the above example, ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to create FFIs to make Python integer interpretable as a Rust ",(0,r.jsx)(n.code,{children:"usize"})," without additional work."]}),"\n",(0,r.jsx)(n.p,{children:"However, automatically interpreted types might not be the most optimized implementation."}),"\n",(0,r.jsx)(n.h3,{id:"implementation-1-default",children:"Implementation 1: Default"}),"\n",(0,r.jsx)(n.p,{children:"Let's imagine that, we want to play with arrays, we want to receive an array input and return an array output between Rust and Python.\nA default inplementation, would look like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list(a: Vec<&PyAny>) -> PyResult> {\n Ok(a)\n}\n\n#[pymodule]\nfn blogpost_ffi(_py: Python, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n m.add_function(wrap_pyfunction!(create_list, m)?)?;\n Ok(())\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",children:["> Calling ",(0,r.jsx)(n.code,{children:"create_list"})," for a very large list like: ",(0,r.jsx)(n.code,{children:"value = [1] * 100_000_000"})," is going to return in ",(0,r.jsx)(n.strong,{children:"2.27s"})," ","\ud83d\ude9c"]}),"\n",(0,r.jsx)(n.p,{children:"That's quite slow... The reason being is that this list is going to be interpret one element at a time in a loop. We can do better by trying to use all elements at the same time."}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Check ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi/blob/main/test_script.py",children:"test_script.py"})," for details on how the function is called."]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"implementation-2-pybytes",children:"Implementation 2: PyBytes"}),"\n",(0,r.jsxs)(n.p,{children:["Let's imagine that our array is a C-contiguous array that can be represented as a ",(0,r.jsx)(n.a,{href:"https://docs.python.org/3/library/stdtypes.html?highlight=bytes#bytes",children:(0,r.jsx)(n.code,{children:"PyBytes"})}),". The code can be optimized by casting the inputs and output as a ",(0,r.jsx)(n.code,{children:"PyBytes"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_bytes<'a>(py: Python<'a>, a: &'a PyBytes) -> PyResult<&'a PyBytes> {\n let s = a.as_bytes();\n\n let output = PyBytes::new_with(py, s.len(), |bytes| {\n bytes.copy_from_slice(s);\n Ok(())\n })?;\n Ok(output)\n}\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",children:["> For the same list input, ",(0,r.jsx)(n.code,{children:"create_list_bytes"})," returns in ",(0,r.jsx)(n.strong,{children:"78 milliseconds"}),". That's ",(0,r.jsx)(n.strong,{children:"30x"})," better ","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"The speedup comes from the possibility to copy the memory range instead of iterating each element and to read without copying."}),"\n",(0,r.jsx)(n.p,{children:"Now the issue is that:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," is only available in Python meaning that if we plan to have other languages, we will have to replicate this for each language."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," might also probably need to be reconverted into other useful types."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," needs a copy to be created."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["We can try to solve this with ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"}),"."]}),"\n",(0,r.jsxs)(n.h3,{id:"implementation-3-apache-arrow",children:["Implementation 3: ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"})]}),"\n",(0,r.jsx)(n.p,{children:"Apache Arrow is a universal memory format available in many languages."}),"\n",(0,r.jsxs)(n.p,{children:["The same function in ",(0,r.jsx)(n.code,{children:"arrow"})," would look like this:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_arrow(py: Python, a: &PyAny) -> PyResult> {\n let arraydata = arrow::array::ArrayData::from_pyarrow(a).unwrap();\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).unwrap();\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .unwrap();\n\n output.to_pyarrow(py)\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",children:["> Same list returns in ",(0,r.jsx)(n.strong,{children:"33 milliseconds"})," . That's ",(0,r.jsx)(n.strong,{children:"2x"})," better than ",(0,r.jsx)(n.code,{children:"PyBytes"})," ","\ud83d\udc0e","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"This is due to having zero copy when sending back the result. The zero-copying is safe because we are reference-counting the array. The array will be deallocating once all reference has been removed."}),"\n",(0,r.jsxs)(n.p,{children:["The benefits of ",(0,r.jsx)(n.code,{children:"arrow"})," is:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"to make zero-copy achievable, scaling better with bigger data."}),"\n",(0,r.jsx)(n.li,{children:"being reusable in other languages. We only have to replace the last line of the function with the export to the other languages."}),"\n",(0,r.jsxs)(n.li,{children:["having many types description including ",(0,r.jsx)(n.code,{children:"List"}),",",(0,r.jsx)(n.code,{children:"Mapping"})," and ",(0,r.jsx)(n.code,{children:"Struct"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["being directly usable in ",(0,r.jsx)(n.code,{children:"numpy"}),", ",(0,r.jsx)(n.code,{children:"pandas"}),", and ",(0,r.jsx)(n.code,{children:"pytorch"})," with zero-copy transmutation."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsx)(n.p,{children:"Dealing with efficient Interface is not the only challenge of bridging multiple languages. We also have to deal with cross-language debugging."}),"\n",(0,r.jsx)(n.h3,{id:"unwrap",children:(0,r.jsx)(n.code,{children:".unwrap()"})}),"\n",(0,r.jsxs)(n.p,{children:["Our current implementation uses ",(0,r.jsx)(n.code,{children:".unwrap()"}),". However, this will panic the whole Python process if there is an error."]}),"\n",(0,r.jsx)(n.h4,{id:"-example-error",children:"> Example error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"thread '' panicked at 'called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }', src/lib.rs:45:62\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\nTraceback (most recent call last):\n File \"/home/peter/Documents/work/blogpost_ffi/test_script.py\", line 79, in \n array = blogpost_ffi.create_list_arrow(1)\npyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }\n"})}),"\n",(0,r.jsx)(n.h3,{id:"eyre",children:(0,r.jsx)(n.a,{href:"https://github.com/eyre-rs/eyre",children:"eyre"})}),"\n",(0,r.jsxs)(n.p,{children:["Eyre is an easy idiomatic error handling library for Rust applications. We can use eyre by wrapping our ",(0,r.jsx)(n.code,{children:"pyo3"})," project with the ",(0,r.jsx)(n.code,{children:"pyo3/eyre"})," feature flag, to replace all our ",(0,r.jsx)(n.code,{children:".unwrap()"})," with a ",(0,r.jsx)(n.code,{children:'.context("our context")?'}),". This will transform unrecoverable errors into recoverable Python errors while giving details about our errors."]}),"\n",(0,r.jsxs)(n.h4,{id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",children:["> Same error as above but with ",(0,r.jsx)(n.code,{children:"eyre"})," which gives a better looking error message:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"Could not convert arrow data\n\nCaused by:\n TypeError: Expected instance of pyarrow.lib.Array, got builtins.int\n\nLocation:\n src/lib.rs:75:50\n"})}),"\n",(0,r.jsx)(n.p,{children:"Implementation details:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn create_list_arrow_eyre(py: Python, a: &PyAny) -> Result> {\n let arraydata =\n arrow::array::ArrayData::from_pyarrow(a).context("Could not convert arrow data")?;\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).context("Could not create pointer")?;\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .context("could not create arrow arraydata")?;\n\n output\n .to_pyarrow(py)\n .context("Could not convert to pyarrow")\n}\n\n'})}),"\n",(0,r.jsxs)(n.h3,{id:"python-traceback-with-eyre",children:["Python traceback with ",(0,r.jsx)(n.code,{children:"eyre"})]}),"\n",(0,r.jsx)(n.p,{children:"I will mention that you might lose the Python traceback error when calling Python code from a Rust code."}),"\n",(0,r.jsx)(n.p,{children:"I recommend using the following custom traceback method to have a descriptive error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn call_func_eyre(py: Python, func: Py) -> Result<()> { \n let _call_python = func.call0(py).context("function called failed")?;\n Ok(())\n}\n\nfn traceback(err: pyo3::PyErr) -> eyre::Report {\n let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok()));\n if let Some(traceback) = traceback {\n eyre::eyre!("{traceback}\\n{err}")\n } else {\n eyre::eyre!("{err}")\n }\n}\n\n#[pyfunction]\nfn call_func_eyre_traceback(py: Python, func: Py) -> Result<()> {\n let _call_python = func\n .call0(py)\n .map_err(traceback) // this will gives python traceback.\n .context("function called failed")?;\n Ok(())\n}\n'})}),"\n",(0,r.jsx)(n.h4,{id:"-example-error-with-no-custom-traceback",children:"> Example error with no custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"---Eyre no traceback---\neyre no traceback says: function called failed\n\nCaused by:\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:89:39\n------\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-better-errors-with-custom-traceback",children:"> Better errors with custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'---Eyre traceback---\neyre traceback says: function called failed\n\nCaused by:\n Traceback (most recent call last):\n File "/home/peter/Documents/work/blogpost_ffi/test_script.py", line 96, in abc\n assert False, "I have no idea what is wrong"\n\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:96:9\n------\n'})}),"\n",(0,r.jsx)(n.p,{children:"With the traceback, we can quickly identify the root error."}),"\n",(0,r.jsx)(n.h2,{id:"memory-management",children:"Memory management"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to create arrays within a loop:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"/// Unbounded memory growth\n#[pyfunction]\nfn unbounded_memory_growth(py: Python) -> Result<()> {\n for _ in 0..10 {\n let a: Vec = vec![0; 40_000_000];\n let _ = PyBytes::new(py, &a);`\n \n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-this-function-will-consume-440mb-of-memory--1",children:["> Calling this function will consume 440MB of memory. ","\ud83d\udc4e"]}),"\n",(0,r.jsxs)(n.p,{children:["What happened is that ",(0,r.jsx)(n.code,{children:"pyo3"})," memory model keeps all Python variables in memory until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["Therefore, if we create variables in a ",(0,r.jsx)(n.code,{children:"pyfunction"})," loop, all temporary variables are going to be kept until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["This is due to ",(0,r.jsx)(n.code,{children:"pyfunction"})," locking the GIL by default."]}),"\n",(0,r.jsx)(n.p,{children:"By understanding the GIL-based memory model, we can use a scoped GIL to have the expected behaviour:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn bounded_memory_growth(py: Python) -> Result<()> {\n py.allow_threads(|| {\n for _ in 0..10 {\n Python::with_gil(|py| {\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n \n std::thread::sleep(Duration::from_secs(1));\n });\n }\n });\n\n // or\n \n for _ in 0..10 {\n let pool = unsafe { py.new_pool() };\n let py = pool.python();\n\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n\n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",children:"> Calling this function will consume 80MB of memory. :thumbsup:"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://pyo3.rs/main/memory.html#gil-bound-memory",children:"More info can be found here"})}),"\n"]}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3/issues/3382",children:"Possible fix in Pyo3 0.21!"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"race-condition",children:"Race condition"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to process data in different threads:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// Function GIL Lock\n#[pyfunction]\nfn gil_lock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("This threaded print was printed after {:#?}", &start_time.elapsed()));\n });\n\n std::thread::sleep(Duration::from_secs(10));\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-this-threaded-print-was-printed-after-100s-cry",children:["> This threaded print was printed after 10.0s. ","\ud83d\ude22"]}),"\n",(0,r.jsxs)(n.p,{children:["When using Python with ",(0,r.jsx)(n.code,{children:"pyo3"}),", we have to make sure to know exactly when the GIL is locked or unlocked to avoid race conditions."]}),"\n",(0,r.jsxs)(n.p,{children:["In the example above, the issue is that by default ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to lock the GIL in the main function thread, therefore blocking the spawned thread that is waiting for the GIL."]}),"\n",(0,r.jsx)(n.p,{children:"If we use the GIL in the main function thread or release the GIL in the main function thread, there is no issue."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn gil_unlock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n std::thread::sleep(Duration::from_secs(10));\n });\n\n Python::with_gil(|py| println!("1. This was printed after {:#?}", &start_time.elapsed()));\n\n // or\n\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("2. This was printed after {:#?}", &start_time.elapsed()));\n });\n Python::with_gil(|py| {\n py.allow_threads(|| {\n std::thread::sleep(Duration::from_secs(10));\n })\n });\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",children:['> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. ',"\ud83d\ude04"]}),"\n",(0,r.jsx)(n.h2,{id:"tracing",children:"Tracing"}),"\n",(0,r.jsx)(n.p,{children:"As we can see, being able to measure the time spent when interfacing can be very valuable to identify bottlenecks."}),"\n",(0,r.jsx)(n.p,{children:"But measuring the time spent manually as we did before can be tedious."}),"\n",(0,r.jsxs)(n.p,{children:["What we can do is use a tracing library to do it for us. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can help us build a distributed observable system capable of bridging multiple languages. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can be used for tracing, metrics and logs."]}),"\n",(0,r.jsx)(n.p,{children:"For example, if we add:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn global_tracing(py: Python, func: Py) {\n // global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());\n global::set_text_map_propagator(TraceContextPropagator::new());\n\n // Connect to Jaeger Opentelemetry endpoint\n // Start a new endpoint with:\n // docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest\n let _tracer = opentelemetry_jaeger::new_agent_pipeline()\n .with_endpoint("172.17.0.1:6831")\n .with_service_name("rust_ffi")\n .install_simple()\n .unwrap();\n\n let tracer = global::tracer("test");\n\n // Parent Trace, first trace\n let _ = tracer.in_span("parent_python_work", |cx| -> Result<()> { \n std::thread::sleep(Duration::from_secs(1));\n \n let mut map = HashMap::new();\n global::get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut map));\n\n let output = func\n .call1(py, (map,))\n .map_err(traceback)\n .context("function called failed")?;\n let out_map: HashMap = output.extract(py).unwrap();\n let out_context = global::get_text_map_propagator(|prop| prop.extract(&out_map));\n\n std::thread::sleep(Duration::from_secs(1));\n\n let _span = tracer.start_with_context("after_python_work", &out_context); // third trace\n\n Ok(())\n });\n}\n'})}),"\n",(0,r.jsx)(n.p,{children:"And the following, in the Python code:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'def abc(cx):\n propagator = TraceContextTextMapPropagator()\n context = propagator.extract(carrier=cx)\n\n with tracing.tracer.start_as_current_span(\n name="Python_span", context=context\n ) as child_span:\n child_span.add_event("in Python!")\n output = {}\n tracing.propagator.inject(output)\n time.sleep(2)\n return output\n'})}),"\n",(0,r.jsx)(n.p,{children:"We will get the following traces:"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:t(69687).A+"",width:"3944",height:"1551"})}),"\n",(0,r.jsx)(n.p,{children:"Using this we can measure the time spent when interfacing languages, identify lock issues, and with the combination of logs and metrics, reduce the complexity of multi-language libraries."}),"\n",(0,r.jsx)(n.h1,{id:"dora-rs",children:(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})}),"\n",(0,r.jsx)(n.p,{children:"Hopefully, this small blog post should help you identify FFI issues."}),"\n",(0,r.jsxs)(n.p,{children:["All optimization above have already been implemented within ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," that lets you build fast and simple dataflows using Rust, Python, C and C++."]}),"\n",(0,r.jsxs)(n.p,{children:["You're very welcome to check out ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," if bridging languages in a dataflow is your usecase."]}),"\n",(0,r.jsxs)(n.p,{children:["We just recently opened a Discord and you can reach out there for literally any question, even just for a quick chat: ",(0,r.jsx)(n.a,{href:"https://discord.gg/DXJ6edAtym",children:"https://discord.gg/DXJ6edAtym"})]}),"\n",(0,r.jsxs)(n.p,{children:["I'm also going to present this FFI work at ",(0,r.jsx)(n.a,{href:"https://workshop2023.gosim.org/schedule#auto",children:"GOSIM Workshop in Shanghai on the 23rd of Sept 2023"}),"!"]}),"\n",(0,r.jsxs)(n.p,{children:["For more info on ",(0,r.jsx)(n.code,{children:"dora-rs"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Github: ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"https://github.com/dora-rs/dora"})]}),"\n",(0,r.jsxs)(n.li,{children:["Website: ",(0,r.jsx)(n.a,{href:"https://www.dora-rs.ai/",children:"https://www.dora-rs.ai/"})]}),"\n",(0,r.jsxs)(n.li,{children:["Discord: ",(0,r.jsx)(n.a,{href:"https://discord.gg/XqhQaN8P",children:"https://discord.gg/XqhQaN8P"})]}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},69687:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/blogpost_ffi-a663a0fdaf6f3a9acc323b2c364d01aa.png"},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>o});var r=t(96540);const a={},s=r.createContext(a);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file +"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[8902],{3321:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>o,toc:()=>c});var r=t(74848),a=t(28453);const s={authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},i=void 0,o={permalink:"/blog/rust-python",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/rust-python.md",source:"@site/blog/rust-python.md",title:"Rust-Python FFI",description:"Rust-Python FFI.",date:"2025-01-13T10:01:54.000Z",tags:[],readingTime:10.8,hasTruncateMarker:!1,authors:[{name:"Haixuan Xavier Tao",title:"Maintainer of dora-rs",url:"https://github.com/haixuantao",imageURL:"https://github.com/haixuantao.png",key:"haixuan"}],frontMatter:{authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},unlisted:!1},l={authorsImageUrls:[void 0]},c=[{value:"Foreign Function Interface",id:"foreign-function-interface",level:2},{value:"Interfacing Arrays",id:"interfacing-arrays",level:2},{value:"Implementation 1: Default",id:"implementation-1-default",level:3},{value:"> Calling create_list for a very large list like: value = [1] * 100_000_000 is going to return in 2.27s \ud83d\ude9c",id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",level:4},{value:"Implementation 2: PyBytes",id:"implementation-2-pybytes",level:3},{value:"> For the same list input, create_list_bytes returns in 78 milliseconds. That's 30x better \ud83d\udc0e",id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",level:4},{value:"Implementation 3: Apache Arrow",id:"implementation-3-apache-arrow",level:3},{value:"> Same list returns in 33 milliseconds . That's 2x better than PyBytes \ud83d\udc0e\ud83d\udc0e",id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",level:4},{value:"Debugging",id:"debugging",level:2},{value:".unwrap()",id:"unwrap",level:3},{value:"> Example error:",id:"-example-error",level:4},{value:"eyre",id:"eyre",level:3},{value:"> Same error as above but with eyre which gives a better looking error message:",id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",level:4},{value:"Python traceback with eyre",id:"python-traceback-with-eyre",level:3},{value:"> Example error with no custom traceback:",id:"-example-error-with-no-custom-traceback",level:4},{value:"> Better errors with custom traceback:",id:"-better-errors-with-custom-traceback",level:4},{value:"Memory management",id:"memory-management",level:2},{value:"> Calling this function will consume 440MB of memory. \ud83d\udc4e",id:"-calling-this-function-will-consume-440mb-of-memory--1",level:4},{value:"> Calling this function will consume 80MB of memory. :thumbsup:",id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",level:4},{value:"Race condition",id:"race-condition",level:2},{value:"> This threaded print was printed after 10.0s. \ud83d\ude22",id:"-this-threaded-print-was-printed-after-100s-cry",level:4},{value:"> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. \ud83d\ude04",id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",level:4},{value:"Tracing",id:"tracing",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:"Writing a rust library that is usable in multiple languages is not easy..."}),"\n",(0,r.jsxs)(n.p,{children:["This blogpost recollects things I have encountered while building ",(0,r.jsx)(n.a,{href:"https://github.com/webonnx/wonnx",children:"wonnx"})," and ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"}),". I am going to use Rust-Python FFI through ",(0,r.jsx)(n.code,{children:"pyo3"})," as an example. You can then extrapolate those issues to other languages FFI."]}),"\n",(0,r.jsx)(n.h2,{id:"foreign-function-interface",children:"Foreign Function Interface"}),"\n",(0,r.jsx)(n.p,{children:"A foreign function interface (FFI) is an interface used to share data from different languages."}),"\n",(0,r.jsxs)(n.p,{children:["By default, python might not know what a Rust ",(0,r.jsx)(n.code,{children:"u16"})," is, so an interface is needed to make the two languages communicate."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://hackmd.io/_uploads/S1qiK8hRh.png",alt:""})}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Image from ",(0,r.jsx)(n.a,{href:"https://hacks.mozilla.org/2019/08/webassembly-interface-types/",children:"WebAssembly Interface Types: Interoperate with All the Things!"})]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"Building interfaces is not easy. Most of the time, we have to use the C-ABI to build our FFI as it is the common denominator between languages."}),"\n",(0,r.jsx)(n.p,{children:"Thankfully, there are FFI libraries that create interfaces for us and we can just focus on the important stuff such as the logic, algorithm, and so on."}),"\n",(0,r.jsx)(n.p,{children:"However, those FFI libraries might have limitations. This is what we're going to discuss."}),"\n",(0,r.jsxs)(n.p,{children:["One example of such FFI library is ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})}),". ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})})," is one of the most used Rust-Python binding and creates FFIs for you. All we have to do is wrap our function with a ",(0,r.jsx)(n.code,{children:"#[pyfunction]"})," and that will make it usable in Python."]}),"\n",(0,r.jsx)(n.h2,{id:"interfacing-arrays",children:"Interfacing Arrays"}),"\n",(0,r.jsxs)(n.p,{children:["In this blog post, I'm going to build a toy Rust-Python project with ",(0,r.jsx)(n.code,{children:"pyo3"})," to illustrate the issues I have faced."]}),"\n",(0,r.jsxs)(n.p,{children:["You can try this blogpost at home by forking the ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi",children:"blogpost repository"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"If you want to start from scratch, you can create a new project with:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"mkdir blogpost_ffi\nmaturin init # pyo3\n"})}),"\n",(0,r.jsx)(n.p,{children:"The default project will looks like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"use pyo3::prelude::*;\n\n/// Formats the sum of two numbers as string.\n#[pyfunction]\nfn sum_as_string(a: usize, b: usize) -> PyResult {\n Ok((a + b).to_string())\n}\n\n/// A Python module implemented in Rust. The name of this function must match\n/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to\n/// import the module.\n#[pymodule]\nfn string_sum(_py: Python<'_>, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"We can call the function as follows:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'maturin develop\npython -c "import blogpost_ffi; print(blogpost_ffi.sum_as_string(1,1))"\n# Return: "2" \n'})}),"\n",(0,r.jsxs)(n.p,{children:["In the above example, ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to create FFIs to make Python integer interpretable as a Rust ",(0,r.jsx)(n.code,{children:"usize"})," without additional work."]}),"\n",(0,r.jsx)(n.p,{children:"However, automatically interpreted types might not be the most optimized implementation."}),"\n",(0,r.jsx)(n.h3,{id:"implementation-1-default",children:"Implementation 1: Default"}),"\n",(0,r.jsx)(n.p,{children:"Let's imagine that, we want to play with arrays, we want to receive an array input and return an array output between Rust and Python.\nA default inplementation, would look like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list(a: Vec<&PyAny>) -> PyResult> {\n Ok(a)\n}\n\n#[pymodule]\nfn blogpost_ffi(_py: Python, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n m.add_function(wrap_pyfunction!(create_list, m)?)?;\n Ok(())\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",children:["> Calling ",(0,r.jsx)(n.code,{children:"create_list"})," for a very large list like: ",(0,r.jsx)(n.code,{children:"value = [1] * 100_000_000"})," is going to return in ",(0,r.jsx)(n.strong,{children:"2.27s"})," ","\ud83d\ude9c"]}),"\n",(0,r.jsx)(n.p,{children:"That's quite slow... The reason being is that this list is going to be interpret one element at a time in a loop. We can do better by trying to use all elements at the same time."}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Check ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi/blob/main/test_script.py",children:"test_script.py"})," for details on how the function is called."]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"implementation-2-pybytes",children:"Implementation 2: PyBytes"}),"\n",(0,r.jsxs)(n.p,{children:["Let's imagine that our array is a C-contiguous array that can be represented as a ",(0,r.jsx)(n.a,{href:"https://docs.python.org/3/library/stdtypes.html?highlight=bytes#bytes",children:(0,r.jsx)(n.code,{children:"PyBytes"})}),". The code can be optimized by casting the inputs and output as a ",(0,r.jsx)(n.code,{children:"PyBytes"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_bytes<'a>(py: Python<'a>, a: &'a PyBytes) -> PyResult<&'a PyBytes> {\n let s = a.as_bytes();\n\n let output = PyBytes::new_with(py, s.len(), |bytes| {\n bytes.copy_from_slice(s);\n Ok(())\n })?;\n Ok(output)\n}\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",children:["> For the same list input, ",(0,r.jsx)(n.code,{children:"create_list_bytes"})," returns in ",(0,r.jsx)(n.strong,{children:"78 milliseconds"}),". That's ",(0,r.jsx)(n.strong,{children:"30x"})," better ","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"The speedup comes from the possibility to copy the memory range instead of iterating each element and to read without copying."}),"\n",(0,r.jsx)(n.p,{children:"Now the issue is that:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," is only available in Python meaning that if we plan to have other languages, we will have to replicate this for each language."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," might also probably need to be reconverted into other useful types."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," needs a copy to be created."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["We can try to solve this with ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"}),"."]}),"\n",(0,r.jsxs)(n.h3,{id:"implementation-3-apache-arrow",children:["Implementation 3: ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"})]}),"\n",(0,r.jsx)(n.p,{children:"Apache Arrow is a universal memory format available in many languages."}),"\n",(0,r.jsxs)(n.p,{children:["The same function in ",(0,r.jsx)(n.code,{children:"arrow"})," would look like this:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_arrow(py: Python, a: &PyAny) -> PyResult> {\n let arraydata = arrow::array::ArrayData::from_pyarrow(a).unwrap();\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).unwrap();\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .unwrap();\n\n output.to_pyarrow(py)\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",children:["> Same list returns in ",(0,r.jsx)(n.strong,{children:"33 milliseconds"})," . That's ",(0,r.jsx)(n.strong,{children:"2x"})," better than ",(0,r.jsx)(n.code,{children:"PyBytes"})," ","\ud83d\udc0e","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"This is due to having zero copy when sending back the result. The zero-copying is safe because we are reference-counting the array. The array will be deallocating once all reference has been removed."}),"\n",(0,r.jsxs)(n.p,{children:["The benefits of ",(0,r.jsx)(n.code,{children:"arrow"})," is:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"to make zero-copy achievable, scaling better with bigger data."}),"\n",(0,r.jsx)(n.li,{children:"being reusable in other languages. We only have to replace the last line of the function with the export to the other languages."}),"\n",(0,r.jsxs)(n.li,{children:["having many types description including ",(0,r.jsx)(n.code,{children:"List"}),",",(0,r.jsx)(n.code,{children:"Mapping"})," and ",(0,r.jsx)(n.code,{children:"Struct"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["being directly usable in ",(0,r.jsx)(n.code,{children:"numpy"}),", ",(0,r.jsx)(n.code,{children:"pandas"}),", and ",(0,r.jsx)(n.code,{children:"pytorch"})," with zero-copy transmutation."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsx)(n.p,{children:"Dealing with efficient Interface is not the only challenge of bridging multiple languages. We also have to deal with cross-language debugging."}),"\n",(0,r.jsx)(n.h3,{id:"unwrap",children:(0,r.jsx)(n.code,{children:".unwrap()"})}),"\n",(0,r.jsxs)(n.p,{children:["Our current implementation uses ",(0,r.jsx)(n.code,{children:".unwrap()"}),". However, this will panic the whole Python process if there is an error."]}),"\n",(0,r.jsx)(n.h4,{id:"-example-error",children:"> Example error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"thread '' panicked at 'called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }', src/lib.rs:45:62\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\nTraceback (most recent call last):\n File \"/home/peter/Documents/work/blogpost_ffi/test_script.py\", line 79, in \n array = blogpost_ffi.create_list_arrow(1)\npyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }\n"})}),"\n",(0,r.jsx)(n.h3,{id:"eyre",children:(0,r.jsx)(n.a,{href:"https://github.com/eyre-rs/eyre",children:"eyre"})}),"\n",(0,r.jsxs)(n.p,{children:["Eyre is an easy idiomatic error handling library for Rust applications. We can use eyre by wrapping our ",(0,r.jsx)(n.code,{children:"pyo3"})," project with the ",(0,r.jsx)(n.code,{children:"pyo3/eyre"})," feature flag, to replace all our ",(0,r.jsx)(n.code,{children:".unwrap()"})," with a ",(0,r.jsx)(n.code,{children:'.context("our context")?'}),". This will transform unrecoverable errors into recoverable Python errors while giving details about our errors."]}),"\n",(0,r.jsxs)(n.h4,{id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",children:["> Same error as above but with ",(0,r.jsx)(n.code,{children:"eyre"})," which gives a better looking error message:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"Could not convert arrow data\n\nCaused by:\n TypeError: Expected instance of pyarrow.lib.Array, got builtins.int\n\nLocation:\n src/lib.rs:75:50\n"})}),"\n",(0,r.jsx)(n.p,{children:"Implementation details:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn create_list_arrow_eyre(py: Python, a: &PyAny) -> Result> {\n let arraydata =\n arrow::array::ArrayData::from_pyarrow(a).context("Could not convert arrow data")?;\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).context("Could not create pointer")?;\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .context("could not create arrow arraydata")?;\n\n output\n .to_pyarrow(py)\n .context("Could not convert to pyarrow")\n}\n\n'})}),"\n",(0,r.jsxs)(n.h3,{id:"python-traceback-with-eyre",children:["Python traceback with ",(0,r.jsx)(n.code,{children:"eyre"})]}),"\n",(0,r.jsx)(n.p,{children:"I will mention that you might lose the Python traceback error when calling Python code from a Rust code."}),"\n",(0,r.jsx)(n.p,{children:"I recommend using the following custom traceback method to have a descriptive error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn call_func_eyre(py: Python, func: Py) -> Result<()> { \n let _call_python = func.call0(py).context("function called failed")?;\n Ok(())\n}\n\nfn traceback(err: pyo3::PyErr) -> eyre::Report {\n let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok()));\n if let Some(traceback) = traceback {\n eyre::eyre!("{traceback}\\n{err}")\n } else {\n eyre::eyre!("{err}")\n }\n}\n\n#[pyfunction]\nfn call_func_eyre_traceback(py: Python, func: Py) -> Result<()> {\n let _call_python = func\n .call0(py)\n .map_err(traceback) // this will gives python traceback.\n .context("function called failed")?;\n Ok(())\n}\n'})}),"\n",(0,r.jsx)(n.h4,{id:"-example-error-with-no-custom-traceback",children:"> Example error with no custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"---Eyre no traceback---\neyre no traceback says: function called failed\n\nCaused by:\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:89:39\n------\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-better-errors-with-custom-traceback",children:"> Better errors with custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'---Eyre traceback---\neyre traceback says: function called failed\n\nCaused by:\n Traceback (most recent call last):\n File "/home/peter/Documents/work/blogpost_ffi/test_script.py", line 96, in abc\n assert False, "I have no idea what is wrong"\n\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:96:9\n------\n'})}),"\n",(0,r.jsx)(n.p,{children:"With the traceback, we can quickly identify the root error."}),"\n",(0,r.jsx)(n.h2,{id:"memory-management",children:"Memory management"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to create arrays within a loop:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"/// Unbounded memory growth\n#[pyfunction]\nfn unbounded_memory_growth(py: Python) -> Result<()> {\n for _ in 0..10 {\n let a: Vec = vec![0; 40_000_000];\n let _ = PyBytes::new(py, &a);`\n \n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-this-function-will-consume-440mb-of-memory--1",children:["> Calling this function will consume 440MB of memory. ","\ud83d\udc4e"]}),"\n",(0,r.jsxs)(n.p,{children:["What happened is that ",(0,r.jsx)(n.code,{children:"pyo3"})," memory model keeps all Python variables in memory until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["Therefore, if we create variables in a ",(0,r.jsx)(n.code,{children:"pyfunction"})," loop, all temporary variables are going to be kept until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["This is due to ",(0,r.jsx)(n.code,{children:"pyfunction"})," locking the GIL by default."]}),"\n",(0,r.jsx)(n.p,{children:"By understanding the GIL-based memory model, we can use a scoped GIL to have the expected behaviour:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn bounded_memory_growth(py: Python) -> Result<()> {\n py.allow_threads(|| {\n for _ in 0..10 {\n Python::with_gil(|py| {\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n \n std::thread::sleep(Duration::from_secs(1));\n });\n }\n });\n\n // or\n \n for _ in 0..10 {\n let pool = unsafe { py.new_pool() };\n let py = pool.python();\n\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n\n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",children:"> Calling this function will consume 80MB of memory. :thumbsup:"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://pyo3.rs/main/memory.html#gil-bound-memory",children:"More info can be found here"})}),"\n"]}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3/issues/3382",children:"Possible fix in Pyo3 0.21!"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"race-condition",children:"Race condition"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to process data in different threads:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// Function GIL Lock\n#[pyfunction]\nfn gil_lock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("This threaded print was printed after {:#?}", &start_time.elapsed()));\n });\n\n std::thread::sleep(Duration::from_secs(10));\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-this-threaded-print-was-printed-after-100s-cry",children:["> This threaded print was printed after 10.0s. ","\ud83d\ude22"]}),"\n",(0,r.jsxs)(n.p,{children:["When using Python with ",(0,r.jsx)(n.code,{children:"pyo3"}),", we have to make sure to know exactly when the GIL is locked or unlocked to avoid race conditions."]}),"\n",(0,r.jsxs)(n.p,{children:["In the example above, the issue is that by default ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to lock the GIL in the main function thread, therefore blocking the spawned thread that is waiting for the GIL."]}),"\n",(0,r.jsx)(n.p,{children:"If we use the GIL in the main function thread or release the GIL in the main function thread, there is no issue."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn gil_unlock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n std::thread::sleep(Duration::from_secs(10));\n });\n\n Python::with_gil(|py| println!("1. This was printed after {:#?}", &start_time.elapsed()));\n\n // or\n\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("2. This was printed after {:#?}", &start_time.elapsed()));\n });\n Python::with_gil(|py| {\n py.allow_threads(|| {\n std::thread::sleep(Duration::from_secs(10));\n })\n });\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",children:['> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. ',"\ud83d\ude04"]}),"\n",(0,r.jsx)(n.h2,{id:"tracing",children:"Tracing"}),"\n",(0,r.jsx)(n.p,{children:"As we can see, being able to measure the time spent when interfacing can be very valuable to identify bottlenecks."}),"\n",(0,r.jsx)(n.p,{children:"But measuring the time spent manually as we did before can be tedious."}),"\n",(0,r.jsxs)(n.p,{children:["What we can do is use a tracing library to do it for us. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can help us build a distributed observable system capable of bridging multiple languages. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can be used for tracing, metrics and logs."]}),"\n",(0,r.jsx)(n.p,{children:"For example, if we add:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn global_tracing(py: Python, func: Py) {\n // global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());\n global::set_text_map_propagator(TraceContextPropagator::new());\n\n // Connect to Jaeger Opentelemetry endpoint\n // Start a new endpoint with:\n // docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest\n let _tracer = opentelemetry_jaeger::new_agent_pipeline()\n .with_endpoint("172.17.0.1:6831")\n .with_service_name("rust_ffi")\n .install_simple()\n .unwrap();\n\n let tracer = global::tracer("test");\n\n // Parent Trace, first trace\n let _ = tracer.in_span("parent_python_work", |cx| -> Result<()> { \n std::thread::sleep(Duration::from_secs(1));\n \n let mut map = HashMap::new();\n global::get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut map));\n\n let output = func\n .call1(py, (map,))\n .map_err(traceback)\n .context("function called failed")?;\n let out_map: HashMap = output.extract(py).unwrap();\n let out_context = global::get_text_map_propagator(|prop| prop.extract(&out_map));\n\n std::thread::sleep(Duration::from_secs(1));\n\n let _span = tracer.start_with_context("after_python_work", &out_context); // third trace\n\n Ok(())\n });\n}\n'})}),"\n",(0,r.jsx)(n.p,{children:"And the following, in the Python code:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'def abc(cx):\n propagator = TraceContextTextMapPropagator()\n context = propagator.extract(carrier=cx)\n\n with tracing.tracer.start_as_current_span(\n name="Python_span", context=context\n ) as child_span:\n child_span.add_event("in Python!")\n output = {}\n tracing.propagator.inject(output)\n time.sleep(2)\n return output\n'})}),"\n",(0,r.jsx)(n.p,{children:"We will get the following traces:"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:t(69687).A+"",width:"3944",height:"1551"})}),"\n",(0,r.jsx)(n.p,{children:"Using this we can measure the time spent when interfacing languages, identify lock issues, and with the combination of logs and metrics, reduce the complexity of multi-language libraries."}),"\n",(0,r.jsx)(n.h1,{id:"dora-rs",children:(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})}),"\n",(0,r.jsx)(n.p,{children:"Hopefully, this small blog post should help you identify FFI issues."}),"\n",(0,r.jsxs)(n.p,{children:["All optimization above have already been implemented within ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," that lets you build fast and simple dataflows using Rust, Python, C and C++."]}),"\n",(0,r.jsxs)(n.p,{children:["You're very welcome to check out ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," if bridging languages in a dataflow is your usecase."]}),"\n",(0,r.jsxs)(n.p,{children:["We just recently opened a Discord and you can reach out there for literally any question, even just for a quick chat: ",(0,r.jsx)(n.a,{href:"https://discord.gg/DXJ6edAtym",children:"https://discord.gg/DXJ6edAtym"})]}),"\n",(0,r.jsxs)(n.p,{children:["I'm also going to present this FFI work at ",(0,r.jsx)(n.a,{href:"https://workshop2023.gosim.org/schedule#auto",children:"GOSIM Workshop in Shanghai on the 23rd of Sept 2023"}),"!"]}),"\n",(0,r.jsxs)(n.p,{children:["For more info on ",(0,r.jsx)(n.code,{children:"dora-rs"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Github: ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"https://github.com/dora-rs/dora"})]}),"\n",(0,r.jsxs)(n.li,{children:["Website: ",(0,r.jsx)(n.a,{href:"https://www.dora-rs.ai/",children:"https://www.dora-rs.ai/"})]}),"\n",(0,r.jsxs)(n.li,{children:["Discord: ",(0,r.jsx)(n.a,{href:"https://discord.gg/XqhQaN8P",children:"https://discord.gg/XqhQaN8P"})]}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},69687:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/blogpost_ffi-a663a0fdaf6f3a9acc323b2c364d01aa.png"},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>o});var r=t(96540);const a={},s=r.createContext(a);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1cd62bc7.ae7e9acf.js b/assets/js/1cd62bc7.c610c713.js similarity index 89% rename from assets/js/1cd62bc7.ae7e9acf.js rename to assets/js/1cd62bc7.c610c713.js index 7742ec7f..b544a4f6 100644 --- a/assets/js/1cd62bc7.ae7e9acf.js +++ b/assets/js/1cd62bc7.c610c713.js @@ -1 +1 @@ -"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[4643],{57832:(t,e,o)=>{o.r(e),o.d(e,{assets:()=>d,contentTitle:()=>n,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var s=o(74848),a=o(28453),i=o(96630);const r={sidebar_position:1},n="Search",l={id:"examples/readme",title:"Search",description:"",source:"@site/docs/examples/readme.mdx",sourceDirName:"examples",slug:"/examples/",permalink:"/docs/examples/",draft:!1,unlisted:!1,editUrl:"https://github.com/dora-rs/dora-rs.github.io/edit/main/docs/examples/readme.mdx",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1},sidebar:"examples",next:{title:"Search",permalink:"/docs/examples/"}},d={},c=[];function p(t){const e={h1:"h1",...(0,a.R)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.h1,{id:"search",children:"Search"}),"\n","\n",(0,s.jsx)(i.Ay,{})]})}function h(t={}){const{wrapper:e}={...(0,a.R)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(p,{...t})}):p(t)}},96630:(t,e,o)=>{o.d(e,{KE:()=>nt,Ay:()=>lt,Ed:()=>$});var s=o(96540),a=o(20053),i=o(38193),r=o(21312),n=o(56347),l=o(53465),d=o(28774);const c={svgIcon:"svgIcon_R3jO",small:"small_SUAn",medium:"medium_GxVq",large:"large_TyPU",primary:"primary_V8Cc",secondary:"secondary_WyIo",success:"success_lY5U",error:"error_eHdq",warning:"warning_IB04",inherit:"inherit_2ln5"};var p=o(74848);function h(t){const{svgClass:e,colorAttr:o,children:s,color:i="inherit",size:r="medium",viewBox:n="0 0 24 24",...l}=t;return(0,p.jsx)("svg",{viewBox:n,color:o,"aria-hidden":!0,className:(0,a.A)(c.svgIcon,c[i],c[r],e),...l,children:s})}function m(t){return(0,p.jsx)(h,{...t,children:(0,p.jsx)("path",{d:"M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"})})}function u(t,e){const o=[...t];return o.sort(((t,o)=>e(t)>e(o)?1:e(o)>e(t)?-1:0)),o}const g=JSON.parse('[{"title":"Yolov5 Operator","description":"Yolov5 object detection operator","preview":"https://i.imgur.com/hPrazyl.jpg","website":"yolov5_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolov5_op.py","tags":["cv","python"]},{"title":"Plot Operator","description":"Plot operator based on cv2","preview":"https://i.imgur.com/ekEgDL5.png","website":"plot_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/plot.py","tags":["python"]},{"title":"PID Operator","description":"PID controller","preview":"https://i.imgur.com/AEmoZ7k.gif","website":"pid_control_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/pid_control_op.py","tags":["python","control"]},{"title":"Obstacle Location Operator","description":"Obstacle location based on LIDAR and 2D bounding boxes","preview":"https://i.imgur.com/Aq33qy5.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/obstacle_location_op.py","tags":["python"]},{"title":"FOT Operator","description":"Waypoint generation based on current position and frenet optimal trajectory planner.","preview":"https://i.imgur.com/klQitzg.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/fot_op.py","tags":["python"]},{"title":"YOLOP Operator","description":"YOLOP lane and drivable area detection","preview":"https://i.imgur.com/I531NIT.gif","website":"yolop_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolop_op.py","tags":["cv","python"]},{"title":"MiDaS Operator","description":"MiDaS depth estimation","preview":"https://i.imgur.com/UrF9iPN.png","website":"midas_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/midas_op.py","tags":["depth_estimation","python"]},{"title":"Webcam Operator","description":"Webcam Operator","preview":"https://i.imgur.com/CC0IW3i.png","website":"webcam_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/webcam_op.py","tags":["python"]},{"title":"Strong Sort Operator","description":"Strong Sort Operator","preview":"https://i.imgur.com/ozO1y7l.gif","website":"strong_sort_op","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/strong_sort_op.py","tags":["cv","python"]}]');var b=o.t(g,2);const y=JSON.parse('[{"title":"Speech to Text","description":"Transform speech to text.","preview":"/img/whisper.png.avif","website":"stt","source":"https://github.com/dora-rs/dora/blob/main/examples/speech-to-text","tags":["audio","python"],"category":"Audio","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fspeech-to-text"},{"title":"Translation","description":"Translate audio in real time.","website":"translation","source":"https://github.com/dora-rs/dora/blob/main/examples/translation","tags":["audio","python"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Ftranslation","category":"Audio"},{"title":"Vision Language Model","description":"Use a VLM to understand images.","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"vlm","source":"https://github.com/dora-rs/dora/blob/main/examples/vlm","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fvlm","tags":["python","image"],"category":"Vision"},{"title":"YOLO","description":"Use YOLO to detect object within image.","preview":"https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-banner.avif","website":"yolo","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":["python","image"],"category":"Vision"},{"title":"Camera","description":"Simple webcam plot example","preview":"https://upload.wikimedia.org/wikipedia/commons/3/35/AdventWebcam.jpg","website":"webcam","source":"https://github.com/dora-rs/dora/blob/main/examples/camera","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcamera","tags":["python","image"],"category":"Vision"},{"title":"Piper RDT","description":"Piper RDT Pipeline","website":"piper","source":"https://github.com/dora-rs/dora/blob/main/examples/piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpiper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","tags":["python","image"],"category":"Training"},{"title":"LeRobot - Alexander Koch","description":"Piper RDT Pipeline","website":"lerobot","source":"https://raw.githubusercontent.com/dora-rs/dora-lerobot/refs/heads/main/README.md","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-lerobot","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","tags":["python","image"],"category":"Training"},{"title":"C Example","description":"Example with C node","website":"c-example","preview":"https://iq.direct/images/C-programming.png","source":"https://github.com/dora-rs/dora/blob/main/examples/c-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ Example","description":"Example with C++ node","website":"c++-example","preview":"https://repository-images.githubusercontent.com/124365799/7d888300-6a39-11ea-9025-fd5574f062c7","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-dataflow","tags":[],"category":"Tutorial"},{"title":"CMake Example","description":"Example using CMake","website":"cmake-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ-IsFXHxaLnZWam5sEJvnUZAzGMyGzXfOKMmIX9XeugcL45yTIuizNbaYi4Y-obbI14A&usqp=CAU","source":"https://github.com/dora-rs/dora/blob/main/examples/cmake-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcmake-dataflow","tags":[],"category":"Tutorial"},{"title":"CUDA Example","description":"Example using CUDA Zero Copy","website":"cuda-example","preview":"https://d29g4g2dyqv443.cloudfront.net/sites/default/files/akamai/ros-dp-nitros.gif","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Tutorial"},{"title":"Rust Example","description":"Example using Rust","website":"rust-example","preview":"https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-light.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-dataflow","tags":[],"category":"Tutorial"},{"title":"Python Example","description":"Example using Python","website":"python-example","preview":"https://upload.wikimedia.org/wikipedia/commons/f/f8/Python_logo_and_wordmark.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":[],"category":"Tutorial"},{"title":"Python ROS2 Example","description":"Example using Python ROS2","website":"python-ros2-example","preview":"https://www.aranacorp.com/wp-content/uploads/python-ros2.png","source":"https://github.com/dora-rs/dora/blob/main/examples/python-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"Rust ROS2 Example","description":"Example using Rust ROS2","website":"rust-ros2-example","preview":"https://robonomics.network/assets/static/cover.d57b2e8.268586f3596831daf0d2d0fa2c885458.jpg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ ROS2 Example","description":"Example using C++ ROS2","website":"c++-ros2-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSnC1cXYAAjFUjNAogVCAr8HrAmumbx9nEnhg&s","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"CPU Benchmark","description":"CPU Benchmark of dora-rs","website":"cpu-benchmark","preview":"https://github.com/user-attachments/assets/3285d183-7560-40e1-ac02-30fee0f120cb","source":"https://github.com/dora-rs/dora-benchmark/blob/main","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-benchmark","tags":[],"category":"Benchmark"},{"title":"GPU Benchmark","description":"GPU Benchmark of dora-rs","website":"gpu-benchmark","preview":"https://github.com/user-attachments/assets/d64370fc-b0ba-46af-be83-19d3c772ada6","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Benchmark"}]');var w=o.t(y,2);const v=JSON.parse('[{"title":"Whisper","description":"Transcribe audio to text","preview":"/img/whisper.png.avif","website":"whisper","github":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-distil-whisper","install":"- id: dora-distil-whisper\\n build: pip install dora-distil-whisper\\n path: dora-distil-whisper\\n inputs: \\n tick: /audio\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-distil-whisper","last_release":"https://img.shields.io/pypi/v/dora-distil-whisper","license":"https://img.shields.io/pypi/l/dora-distil-whisper","category":"Speech to Text"},{"title":"Qwenvl","description":"Vision Language Model","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"qwenvl","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-qwenvl","install":"- id: dora-qwenvl\\n build: pip install dora-qwenvl\\n path: dora-qwenvl\\n inputs: \\n text: /text\\n image: /image\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-qwenvl","tags":["python","image","text"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-qwenvl","last_release":"https://img.shields.io/pypi/v/dora-qwenvl","license":"https://img.shields.io/pypi/l/dora-qwenvl","category":"Vision Language Model"},{"title":"Silero VAD","description":"Silero Voice activity detection","preview":"https://user-images.githubusercontent.com/12515440/89997349-b3523080-dc94-11ea-9906-ca2e8bc50535.png","website":"silero","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-vad","install":"- id: dora-vad\\n build: pip install dora-vad\\n path: dora-vad\\n inputs: \\n tick: /audio\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-vad","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-vad","last_release":"https://img.shields.io/pypi/v/dora-vad","license":"https://img.shields.io/pypi/l/dora-vad","category":"Voice Activity Detection"},{"title":"Microphone","description":"Audio from microphone","author":"dora","website":"microphone","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8EPOj0PAu4yyERZg4ncm-vMgBqaU5lSP6_Q&s","downloads":"https://img.shields.io/pypi/dm/dora-microphone","install":"- id: dora-microphone\\n build: pip install dora-microphone\\n path: dora-microphone\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-microphone","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-microphone","last_release":"https://img.shields.io/pypi/v/dora-microphone","license":"https://img.shields.io/pypi/l/dora-microphone","category":"Peripheral"},{"title":"Rerun","description":"Visualization tool","author":"dora","website":"rerun","downloads":"https://img.shields.io/pypi/dm/dora-rerun","install":"- id: dora-rerun\\n build: pip install dora-rerun\\n path: dora-rerun\\n inputs: \\n image: /image\\n text: /text","preview":"https://user-images.githubusercontent.com/1148717/218141237-0442d2b5-ed22-42bf-9321-10af1b894507.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rerun","tags":["rust","text","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rerun","last_release":"https://img.shields.io/pypi/v/dora-rerun","license":"https://img.shields.io/pypi/l/dora-rerun","category":"Visualization"},{"title":"Video Capture","description":"Image stream from Camera","author":"dora","website":"opencv-video-capture","install":"- id: opencv-video-capture\\n build: pip install opencv-video-capture\\n path: opencv-video-capture\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image","downloads":"https://img.shields.io/pypi/dm/opencv-video-capture","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-video-capture","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-video-capture","last_release":"https://img.shields.io/pypi/v/opencv-video-capture","license":"https://img.shields.io/pypi/l/opencv-video-capture","tags":["python","image"],"category":"Camera"},{"title":"Yolov8","description":"Object detection","author":"dora","website":"yolo","install":"- id: dora-yolo\\n build: pip install dora-yolo\\n path: dora-yolo\\n inputs: \\n image: /image\\n outputs: \\n - bbox","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-yolo","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-yolo","last_release":"https://img.shields.io/pypi/v/dora-yolo","license":"https://img.shields.io/pypi/l/dora-yolo","tags":["python","image"],"category":"Object Detection"},{"title":"Plot","description":"Simple OpenCV plot visualization","author":"dora","website":"opencv-plot","install":"- id: opencv-plot\\n build: pip install opencv-plot\\n path: opencv-plot\\n inputs: \\n image: /image\\n text: /text","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-plot","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-plot","last_release":"https://img.shields.io/pypi/v/opencv-plot","license":"https://img.shields.io/pypi/l/opencv-plot","tags":["python","image","text"],"category":"Visualization"},{"title":"PyRealsense","description":"Image and depth from Realsense","author":"dora","website":"pyrealsense","install":"- id: dora-pyrealsense\\n build: pip install dora-pyrealsense\\n path: dora-pyrealsense\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth","downloads":"https://img.shields.io/pypi/dm/dora-pyrealsense","preview":"https://user-images.githubusercontent.com/41145062/193884336-c30397be-2cac-45da-ba34-07e7db9843e8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyrealsense","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyrealsense","last_release":"https://img.shields.io/pypi/v/dora-pyrealsense","license":"https://img.shields.io/pypi/l/dora-pyrealsense","tags":["python","image","depth"],"category":"Camera"},{"title":"PyOrbbeckSDK","description":"Image and depth from Orbbeck Camera","author":"dora","website":"pyorbbecsdk","install":"- id: dora-pyorbbecksdk\\n build: pip install dora-pyorbbecksdk\\n path: dora-pyorbbecksdk\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth\\n - image_depth","downloads":"https://img.shields.io/pypi/dm/dora-pyorbbecksdk","preview":"https://new-orbbec3d-s3.s3.amazonaws.com/wp-content/uploads/2024/06/03120334/\u53f345\u5ea6-e1717416268437-300x153.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyorbbecksdk","tags":["python","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyorbbecksdk","last_release":"https://img.shields.io/pypi/v/dora-pyorbbecksdk","license":"https://img.shields.io/pypi/l/dora-pyorbbecksdk","category":"Camera"},{"title":"Keyboard","description":"Keyboard char listener","author":"dora","website":"keyboard","install":"- id: dora-keyboard\\n build: pip install dora-keyboard\\n path: dora-keyboard\\n inputs: \\n tick: dora/timer/millis/1000\\n outputs: \\n - char","downloads":"https://img.shields.io/pypi/dm/dora-keyboard","preview":"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/LenovoKeyboard.jpg/220px-LenovoKeyboard.jpg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-keyboard","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-keyboard","last_release":"https://img.shields.io/pypi/v/dora-keyboard","license":"https://img.shields.io/pypi/l/dora-keyboard","tags":["python","text"],"category":"Peripheral"},{"title":"Agilex - Piper","description":"Agilex arm client","author":"dora","website":"piper","install":"- id: dora-piper\\n build: pip install dora-piper\\n path: dora-piper\\n inputs: \\n tick: dora/timer/millis/20\\n joint_action: /jointstate\\n outputs: \\n - jointstate","downloads":"https://img.shields.io/pypi/dm/dora-piper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-piper","last_release":"https://img.shields.io/pypi/v/dora-piper","license":"https://img.shields.io/pypi/l/dora-piper","tags":["python"],"category":"Arm"},{"title":"Opus MT","description":"Translate text between language","author":"dora","website":"opus","install":"- id: dora-opus\\n build: pip install dora-opus\\n path: dora-opus\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","downloads":"https://img.shields.io/pypi/dm/dora-opus","preview":"https://github.com/Helsinki-NLP/Opus-MT/raw/master/img/opus_mt.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-opus","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-opus","last_release":"https://img.shields.io/pypi/v/dora-opus","license":"https://img.shields.io/pypi/l/dora-opus","tags":["python","text"],"category":"Translation"},{"title":"Llama Factory Recorder","description":"Record data to train LLM and VLM","author":"dora","website":"llama-factory-recorder","install":"- id: llama-factory-recorder\\n build: pip install llama-factory-recorder\\n path: llama-factory-recorder\\n inputs: \\n image: /image\\n text: /text\\n ground_truth: /text\\n outputs: \\n - text","downloads":"https://img.shields.io/pypi/dm/llama-factory-recorder","preview":"https://github.com/hiyouga/LLaMA-Factory/blob/main/assets/logo.png?raw=true","source":"https://github.com/dora-rs/dora/blob/main/node-hub/llama-factory-recorder","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fllama-factory-recorder","last_release":"https://img.shields.io/pypi/v/llama-factory-recorder","license":"https://img.shields.io/pypi/l/llama-factory-recorder","tags":["python","image","text"],"category":"Recorder"},{"title":"RDT-1B","description":"Infer policy using Robotic Diffusion Transformer","author":"dora","website":"rdt","install":"- id: dora-rdt-1b\\n build: pip install dora-rdt-1b\\n path: dora-rdt-1b\\n inputs: \\n image: /image\\n jointstate: /jointstate\\n outputs: \\n - action","downloads":"https://img.shields.io/pypi/dm/dora-rdt-1b","preview":"https://github.com/thu-ml/RoboticsDiffusionTransformer/raw/main/assets/head.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rdt-1b","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rdt-1b","last_release":"https://img.shields.io/pypi/v/dora-rdt-1b","license":"https://img.shields.io/pypi/l/dora-rdt-1b","tags":["python","image","text"],"category":"Vision Language Action"},{"title":"Dynamixel","description":"Dynamixel Client","author":"Enzo Levan","website":"dynamixel","preview":"https://robots.ros.org/assets/img/robots/dynamixel/dynamixel.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dynamixel-client","tags":["python"],"category":"Actuator"},{"title":"Feetech","description":"Feetech Client","author":"Enzo Levan","website":"feetech","preview":"https://media.licdn.com/dms/image/v2/C5612AQGpeiwwIPDqaw/article-cover_image-shrink_720_1280/article-cover_image-shrink_720_1280/0/1647414552058?e=2147483647&v=beta&t=QoHYcvm7pla6ptYtg3daKPAGRRctKGEkIGkBrGyE25Y","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/feetech-client","tags":["python"],"category":"Actuator"},{"title":"Mujoco","description":"Mujoco Simulator","author":"Enzo Levan","website":"mujoco","preview":"https://github.com/google-deepmind/mujoco/raw/main/banner.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/mujoco-client","tags":["python"],"category":"Simulator"},{"title":"Lebai - LM3","description":"Lebai client","author":"dora","website":"lebai","preview":"https://l-www.lebai.ltd/2015/07/1-495x400.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lebai-client","tags":["python"],"category":"Arm"},{"title":"Alex Koch - Low Cost Robot","description":"Alex Koch - Low Cost Robot Client","author":"dora","website":"alex-koch-low-cost-robot","preview":"https://github.com/AlexanderKoch-Koch/low_cost_robot/raw/main/pictures/robot_portait.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/alexk-lcr","tags":["python"],"category":"Arm"},{"title":"Trossen - Aloha","description":"Aloha client","author":"dora","website":"aloha","preview":"https://static.wixstatic.com/media/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg/v1/fill/w_1000,h_659,al_c,q_85,usm_0.66_1.00_0.01/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/aloha","tags":["python"],"category":"Robot"},{"title":"Pollen - Reachy 2","description":"Reachy 2 client","author":"dora","website":"reachy2","preview":"https://www.lejournaldesentreprises.com/sites/lejournaldesentreprises.com/files/styles/landscape_web_lg_1x/public/2024-11/Reachy-2-sait-reprer-un-objet-le-saisir-et-le-m-15512511.jpeg?itok=syrnHhWx","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/reachy","tags":["python"],"category":"Robot"},{"title":"Carla","description":"Carla Simulator","author":"dora","website":"carla","preview":"https://media.licdn.com/dms/image/v2/D4D1BAQHyb4EFail-wQ/company-background_10000/company-background_10000/0/1663774857825/carla_simulator_cover?e=2147483647&v=beta&t=AmftWPQMtfni1t_RXUvqqkQJqxKK_I54BoHpLLSwjWE","source":"https://github.com/dora-rs/dora-drives","tags":["python"],"category":"Simulator"},{"title":"Pollen - Reachy 1","description":"Reachy 1 Client","author":"dora","website":"reachy1","install":"- id: dora-reachy1\\n build: pip install dora-reachy1\\n path: dora-reachy1","preview":"https://www.aquitaineonline.com/images/stories/Economie_Industrie_2021/Reachy_01.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dora-reachy1","tags":["python"],"category":"Robot"},{"title":"DJI - Robomaster S1","description":"Robomaster Client","author":"dora","website":"robomaster-s1","preview":"https://m.media-amazon.com/images/I/61K2UXjfHwL.jpg","source":"https://huggingface.co/datasets/dora-rs/dora-robomaster","tags":["python"],"category":"Chassis"},{"title":"Agilex - UGV","description":"Robomaster Client","author":"dora","website":"robomaster-s1","downloads":"https://img.shields.io/pypi/dm/dora-ugv","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvTwJ589Zudgva9TIQ79ddJ8wHUq2_jmrUZg&s","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-ugv","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-ugv","last_release":"https://img.shields.io/pypi/v/dora-ugv","license":"https://img.shields.io/pypi/l/dora-ugv","tags":["python"],"category":"Chassis"},{"title":"Dora Kit Car","description":"Open Source Chassis","author":"dora","website":"dora-kit-car","downloads":"https://img.shields.io/pypi/dm/dora-kit-car","preview":"https://github.com/RuPingCen/mick_robot_chassis/raw/master/README.assets/fengmian.gif","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-kit-car","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-kit-car","last_release":"https://img.shields.io/pypi/v/dora-kit-car","license":"https://img.shields.io/pypi/l/dora-kit-car","tags":["python"],"category":"Chassis"},{"title":"ArgosTranslate","description":"Open Source translation engine","author":"dora","website":"argotranslate","downloads":"https://img.shields.io/pypi/dm/dora-argotranslate","install":"- id: dora-argotranslate\\n build: pip install dora-argotranslate\\n path: dora-argotranslate\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","preview":"https://avatars.githubusercontent.com/u/48267258?v=4","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-argotranslate","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-argotranslate","last_release":"https://img.shields.io/pypi/v/dora-argotranslate","license":"https://img.shields.io/pypi/l/dora-argotranslate","tags":["python"],"category":"Translation"},{"title":"InternVL","description":"InternVL is a vision language model","author":"dora","website":"internvl","downloads":"https://img.shields.io/pypi/dm/dora-internvl","preview":"https://private-user-images.githubusercontent.com/23737120/379689418-930e6814-8a9f-43e1-a284-118a5732daa4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYzNDcwODEsIm5iZiI6MTczNjM0Njc4MSwicGF0aCI6Ii8yMzczNzEyMC8zNzk2ODk0MTgtOTMwZTY4MTQtOGE5Zi00M2UxLWEyODQtMTE4YTU3MzJkYWE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA4VDE0MzMwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3YTUyM2UyMDc5ZmMxNjk5NWZmNzg4ZjgxN2VkNzIyOTFmYjc2OGJiZGJlOWQ1Y2Q4NWU2OTJhYmRjMzZhZjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uiWkdjPEgeUJkiCVNii9Huh4M1ykJ2Cm_FVcTDcldYs","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-internvl","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-internvl","last_release":"https://img.shields.io/pypi/v/dora-internvl","license":"https://img.shields.io/pypi/l/dora-internvl","tags":["python"],"category":"Vision Language Model"},{"title":"LeRobot Recorder","description":"LeRobot Recorder helper","author":"dora","website":"lerobot-dashboard","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lerobot-dashboard","tags":["python"],"category":"Recorder"},{"title":"Gymnasium","description":"Experimental OpenAI Gymnasium bridge","author":"dora","website":"gymnasium","preview":"https://raw.githubusercontent.com/Farama-Foundation/Gymnasium/main/gymnasium-text.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/gym_dora","tags":["python"],"category":"Simulator"}]');var x=o.t(v,2);const f=["Camera","Peripheral","Actuator","Chassis","Arm","Robot","Voice Activity Detection","Speech to Text","Object Detection","Vision Language Model","Large Language Model","Vision Language Action","Translation","Text to Speech","Recorder","Visualization","Simulator"],_=["Audio","Vision","Training","Tutorial","Benchmark"],j={image:{label:(0,r.T)({id:"showcase.tag.image.tag",message:"image"}),description:(0,r.T)({message:"Computer vision related nodes!",id:"showcase.tag.image.description"}),color:"#39ca30"},python:{label:(0,r.T)({id:"showcase.tag.python.tag",message:"python"}),description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.python.description"}),color:"#dfd545"},rust:{label:"rust",description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.rust.description"}),color:"#333e2e"},control:{label:(0,r.T)({id:"showcase.tag.control.tag",message:"control"}),description:(0,r.T)({message:"Beautiful Docusaurus sites, polished and standing out from the initial template!",id:"showcase.tag.control.description"}),color:"#a44fb7"},depth:{label:(0,r.T)({id:"showcase.tag.depth.tag",message:"depth"}),description:(0,r.T)({message:"Translated Docusaurus sites using the internationalization support with more than 1 locale.",id:"showcase.tag.depth.description"}),color:"#127f82"},audio:{label:(0,r.T)({message:"audio"}),description:(0,r.T)({message:"Docusaurus sites using the versioning feature of the docs plugin to manage multiple versions.",id:"showcase.tag.audio.description"}),color:"#fe6829"},text:{label:(0,r.T)({message:"text"}),description:(0,r.T)({message:"Very large Docusaurus sites, including many more pages than the average!",id:"showcase.tag.large.description"}),color:"#8c2f00"}},k=Object.keys(j),C=b,E=w,L=x;!function(){let t=C.default;t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite")))}();const N=function(){let t=E.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();const A=function(){let t=L.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();var T=o(51107);const O="checkboxLabel_0lFL",F="tags";function R(t){return new URLSearchParams(t).getAll(F)}function S(t,e){let{id:o,icon:a,label:i,tag:r,...l}=t;const d=(0,n.zy)(),c=(0,n.W6)(),[h,m]=(0,s.useState)(!1);(0,s.useEffect)((()=>{const t=R(d.search);m(t.includes(r))}),[r,d]);const u=(0,s.useCallback)((()=>{const t=function(t,e){const o=t.indexOf(e);if(-1===o)return t.concat(e);const s=[...t];return s.splice(o,1),s}(R(d.search),r),e=function(t,e){const o=new URLSearchParams(t);return o.delete(F),e.forEach((t=>o.append(F,t))),o.toString()}(d.search,t);c.push({...d,search:e,state:$()})}),[r,d,c]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("input",{type:"checkbox",id:o,className:"screen-reader-only",onKeyDown:t=>{"Enter"===t.key&&u()},onFocus:t=>{t.relatedTarget&&t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("focus"))},onBlur:t=>{t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("blur"))},onChange:u,checked:h,...l}),(0,p.jsxs)("label",{ref:e,htmlFor:o,className:O,children:[i,a]})]})}const I=s.forwardRef(S),D={checkboxLabel:"checkboxLabel_tOkT"},M="operator";function P(t){return new URLSearchParams(t).get(M)??"OR"}function U(){const t="showcase_filter_toggle",e=(0,n.zy)(),o=(0,n.W6)(),[i,r]=(0,s.useState)(!1);(0,s.useEffect)((()=>{r("AND"===P(e.search))}),[e]);const l=(0,s.useCallback)((()=>{r((t=>!t));const t=new URLSearchParams(e.search);t.delete(M),i||t.append(M,"AND"),o.push({...e,search:t.toString(),state:$()})}),[i,e,o]);return(0,p.jsxs)("div",{children:[(0,p.jsx)("input",{type:"checkbox",id:t,className:"screen-reader-only","aria-label":"Toggle between or and and for the tags you selected",onChange:l,onKeyDown:t=>{"Enter"===t.key&&l()},checked:i}),(0,p.jsxs)("label",{htmlFor:t,className:(0,a.A)(D.checkboxLabel,"shadow--md"),children:[(0,p.jsx)("span",{className:D.checkboxLabelOr,children:"OR"}),(0,p.jsx)("span",{className:D.checkboxLabelAnd,children:"AND"})]})]})}var V=o(40961),z=o(50991);const G={tooltip:"tooltip_vy6_",tooltipArrow:"tooltipArrow_lQYZ"};function B(t){let{children:e,id:o,anchorEl:a,text:i}=t;const[r,n]=(0,s.useState)(!1),[l,d]=(0,s.useState)(null),[c,h]=(0,s.useState)(null),[m,u]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),{styles:y,attributes:w}=(0,z.E)(l,c,{modifiers:[{name:"arrow",options:{element:m}},{name:"offset",options:{offset:[0,8]}}]}),v=(0,s.useRef)(null),x=`${o}_tooltip`;return(0,s.useEffect)((()=>{b(a?"string"==typeof a?document.querySelector(a):a:document.body)}),[g,a]),(0,s.useEffect)((()=>{const t=["mouseenter","focus"],e=["mouseleave","blur"],o=()=>{""!==i&&(l?.removeAttribute("title"),v.current=window.setTimeout((()=>{n(!0)}),400))},s=()=>{clearInterval(v.current),n(!1)};return l&&(t.forEach((t=>{l.addEventListener(t,o)})),e.forEach((t=>{l.addEventListener(t,s)}))),()=>{l&&(t.forEach((t=>{l.removeEventListener(t,o)})),e.forEach((t=>{l.removeEventListener(t,s)})))}}),[l,i]),(0,p.jsxs)(p.Fragment,{children:[s.cloneElement(e,{ref:d,"aria-describedby":r?x:void 0}),g?V.createPortal(r&&(0,p.jsxs)("div",{id:x,role:"tooltip",ref:h,className:G.tooltip,style:y.popper,...w.popper,children:[i,(0,p.jsx)("span",{ref:u,className:G.tooltipArrow,style:y.arrow})]}),g):g]})}const W={showcaseCardImage:"showcaseCardImage_RonU",showcaseCardHeader:"showcaseCardHeader_DBrh",showcaseCardHeaderNoImage:"showcaseCardHeaderNoImage_I3oL",showcaseCardTitle:"showcaseCardTitle_c4K_",svgIconFavorite:"svgIconFavorite_eNhx",showcaseCardSrcBtn:"showcaseCardSrcBtn_zC6u",showcaseCardBody:"showcaseCardBody_Uq33",cardFooter:"cardFooter_jnMp",tag:"tag_rgoW",textLabel:"textLabel_Um7W",colorLabel:"colorLabel_wSaw"};var Y=o(21432);const q=s.forwardRef(((t,e)=>{let{label:o,color:s,description:a}=t;return(0,p.jsxs)("li",{ref:e,className:W.tag,title:a,children:[(0,p.jsx)("span",{className:W.textLabel,children:o.toLowerCase()}),(0,p.jsx)("span",{className:W.colorLabel,style:{backgroundColor:s}})]})}));function J(t){let{tags:e}=t;const o=u(e.map((t=>({tag:t,...j[t]}))),(t=>k.indexOf(t.tag)));return(0,p.jsx)(p.Fragment,{children:o.map(((t,e)=>{const o=`showcase_card_tag_${t.tag}`;return(0,p.jsx)(B,{text:t.description,anchorEl:"#__docusaurus",id:o,children:(0,p.jsx)(q,{...t},e)},e)}))})}function Z(t){let{user:e}=t;!function(t){t.preview}(e);const o=e.source;return(0,p.jsxs)("li",{className:"card shadow--md",children:[(0,p.jsxs)("div",{className:(0,a.A)("card__image",W.showcaseCardImage),children:[e.preview&&(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,style:{height:"150px",display:"flex"},children:(0,p.jsx)("img",{src:e.preview,style:{margin:"auto"},alt:" "})}),null==e.preview&&(0,p.jsx)("h2",{className:W.showcaseCardHeaderNoImage,children:e.title})]}),(0,p.jsxs)("div",{className:"card__body",children:[(0,p.jsxs)("div",{className:(0,a.A)(W.showcaseCardHeader),children:[(0,p.jsxs)(T.A,{as:"h4",className:W.showcaseCardTitle,children:[(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,children:e.title}),e.author&&(0,p.jsxs)("em",{style:{color:"grey"},children:[" by ",e.author]})]}),e.tags.includes("favorite")&&(0,p.jsx)(m,{svgClass:W.svgIconFavorite,size:"small"}),e.source&&(0,p.jsx)(d.A,{href:e.source,className:(0,a.A)("button button--secondary button--sm",W.showcaseCardSrcBtn),children:(0,p.jsx)("img",{src:"/img/github.svg",width:"20px"})})]}),(0,p.jsx)("p",{className:W.showcaseCardBody,children:e.description}),e.install&&(0,p.jsx)("div",{children:(0,p.jsxs)("details",{children:[(0,p.jsx)("summary",{children:(0,p.jsx)("em",{children:"Try it with..."})}),(0,p.jsx)(Y.A,{language:"yaml",children:e.install})]})})]}),(0,p.jsxs)("ul",{className:(0,a.A)("card__footer",W.cardFooter),children:[(0,p.jsxs)("div",{children:[e.downloads&&(0,p.jsx)("img",{className:"margin-right--sm",src:e.downloads}),e.last_commit&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last commit",src:e.last_commit}),e.last_release&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last release",src:e.last_release}),e.license&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub license",src:e.license})]}),(0,p.jsx)("div",{children:(0,p.jsx)(J,{tags:e.tags})})]})]},e.title)}const Q=s.memo(Z),X={filterCheckbox:"filterCheckbox_Feyr",checkboxList:"checkboxList_jTdS",checkboxListItem:"checkboxListItem_dFB0",searchContainer:"searchContainer_s3C6",showcaseList:"showcaseList_CRXj",showcaseFavorite:"showcaseFavorite_XwQD",showcaseFavoriteHeader:"showcaseFavoriteHeader_o0j3",svgIconFavoriteXs:"svgIconFavoriteXs_kiRS",svgIconFavorite:"svgIconFavorite_QxXa"},H=((0,r.T)({message:"dora-rs nodes hub"}),(0,r.T)({message:"List of Nodes already implemented by the community"})),K="https://discord.com/channels/1146393916472561734/1148336336294662196";function $(){if(i.A.canUseDOM)return{scrollTopPosition:window.scrollY,focusedElementId:document.activeElement?.id}}const tt="name";function et(t){return new URLSearchParams(t).get(tt)}function ot(t){const e=(0,n.zy)(),[o,a]=(0,s.useState)("OR"),[i,r]=(0,s.useState)([]),[l,d]=(0,s.useState)(null);return(0,s.useEffect)((()=>{r(R(e.search)),a(P(e.search)),d(et(e.search)),function(t){const{scrollTopPosition:e,focusedElementId:o}=t??{scrollTopPosition:0,focusedElementId:void 0};document.getElementById(o)?.focus(),window.scrollTo({top:e})}(e.state)}),[e]),(0,s.useMemo)((()=>function(t,e,o,s){return s&&(t=t.filter((t=>t.title.toLowerCase().includes(s.toLowerCase())))),0===e.length?t:t.filter((t=>0!==t.tags.length&&("AND"===o?e.every((e=>t.tags.includes(e))):e.some((e=>t.tags.includes(e))))))}(t,i,o,l)),[i,o,l])}function st(){return(0,p.jsxs)("section",{className:"margin-top--lg margin-bottom--lg text--center",children:[(0,p.jsx)("p",{children:H}),(0,p.jsx)(d.A,{className:"button button--primary",to:K,children:(0,p.jsx)(r.A,{id:"showcase.header.button",children:"\ud83d\ude4f Please add your Nodes"})})]})}function at(t){let{sortedExamples:e}=t;const o=ot(e),s=function(){const{selectMessage:t}=(0,l.W)();return e=>t(e,(0,r.T)({id:"showcase.filters.resultCount",description:'Pluralized label for the number of sites found on the showcase. Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',message:"1 site|{sitesCount} sites"},{sitesCount:e}))}();return(0,p.jsxs)("section",{className:"container margin-top--l margin-bottom--lg",children:[(0,p.jsxs)("div",{className:(0,a.A)("margin-bottom--sm",X.filterCheckbox),children:[(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.filters.title",children:"Filters"})}),(0,p.jsx)("span",{children:s(o.length)})]}),(0,p.jsx)(U,{})]}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.checkboxList),children:k.map(((t,e)=>{const{label:o,description:s,color:a}=j[t],i=`showcase_checkbox_id_${t}`;return(0,p.jsx)("li",{className:X.checkboxListItem,children:(0,p.jsx)(B,{id:i,text:s,anchorEl:"#__docusaurus",children:(0,p.jsx)(I,{tag:t,id:i,label:o,icon:"favorite"===t?(0,p.jsx)(m,{svgClass:X.svgIconFavoriteXs}):(0,p.jsx)("span",{style:{backgroundColor:a,width:10,height:10,borderRadius:"50%",marginLeft:8}})})})},e)}))})]})}function it(){const t=(0,n.W6)(),e=(0,n.zy)(),[o,a]=(0,s.useState)(null);return(0,s.useEffect)((()=>{a(et(e.search))}),[e]),(0,p.jsx)("div",{className:X.searchContainer,children:(0,p.jsx)("input",{id:"searchbar",placeholder:(0,r.T)({message:"Search for site name...",id:"showcase.searchBar.placeholder"}),value:o??void 0,onInput:o=>{a(o.currentTarget.value);const s=new URLSearchParams(e.search);s.delete(tt),o.currentTarget.value&&s.set(tt,o.currentTarget.value),t.push({...e,search:s.toString(),state:$()}),setTimeout((()=>{document.getElementById("searchbar")?.focus()}),0)}})})}function rt(t){let{sortedExamples:e,Categories:o}=t;const s=ot(e);return 0===s.length?(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container padding-vert--md text--center",children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.usersList.noResult",children:"No result"})}),(0,p.jsx)(it,{})]})}):(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container",children:[(0,p.jsx)("div",{className:(0,a.A)("margin-bottom--md",X.showcaseFavoriteHeader),children:(0,p.jsx)(it,{})}),(0,p.jsx)("div",{children:o.map((t=>{let e=s.filter((e=>e.category==t));return 0===e.length?null:(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:t}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.showcaseList),children:e.map((t=>(0,p.jsx)(Q,{user:t},t.title)))})]})}))})]})})}function nt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(st,{}),(0,p.jsx)(at,{sortedExamples:A}),(0,p.jsx)(rt,{sortedExamples:A,Categories:f})]})}function lt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(st,{}),(0,p.jsx)(at,{sortedExamples:N}),(0,p.jsx)(rt,{sortedExamples:N,Categories:_})]})}}}]); \ No newline at end of file +"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[4643],{57832:(t,e,o)=>{o.r(e),o.d(e,{assets:()=>d,contentTitle:()=>n,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var s=o(74848),a=o(28453),i=o(96630);const r={sidebar_position:1},n="Search",l={id:"examples/readme",title:"Search",description:"",source:"@site/docs/examples/readme.mdx",sourceDirName:"examples",slug:"/examples/",permalink:"/docs/examples/",draft:!1,unlisted:!1,editUrl:"https://github.com/dora-rs/dora-rs.github.io/edit/main/docs/examples/readme.mdx",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1},sidebar:"examples",next:{title:"Search",permalink:"/docs/examples/"}},d={},c=[];function p(t){const e={h1:"h1",...(0,a.R)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.h1,{id:"search",children:"Search"}),"\n","\n",(0,s.jsx)(i.Ay,{})]})}function h(t={}){const{wrapper:e}={...(0,a.R)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(p,{...t})}):p(t)}},96630:(t,e,o)=>{o.d(e,{KE:()=>rt,Ay:()=>nt,Ed:()=>K});var s=o(96540),a=o(20053),i=o(38193),r=o(21312),n=o(56347),l=o(53465),d=o(28774);const c={svgIcon:"svgIcon_R3jO",small:"small_SUAn",medium:"medium_GxVq",large:"large_TyPU",primary:"primary_V8Cc",secondary:"secondary_WyIo",success:"success_lY5U",error:"error_eHdq",warning:"warning_IB04",inherit:"inherit_2ln5"};var p=o(74848);function h(t){const{svgClass:e,colorAttr:o,children:s,color:i="inherit",size:r="medium",viewBox:n="0 0 24 24",...l}=t;return(0,p.jsx)("svg",{viewBox:n,color:o,"aria-hidden":!0,className:(0,a.A)(c.svgIcon,c[i],c[r],e),...l,children:s})}function m(t){return(0,p.jsx)(h,{...t,children:(0,p.jsx)("path",{d:"M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"})})}function u(t,e){const o=[...t];return o.sort(((t,o)=>e(t)>e(o)?1:e(o)>e(t)?-1:0)),o}const g=JSON.parse('[{"title":"Yolov5 Operator","description":"Yolov5 object detection operator","preview":"https://i.imgur.com/hPrazyl.jpg","website":"yolov5_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolov5_op.py","tags":["cv","python"]},{"title":"Plot Operator","description":"Plot operator based on cv2","preview":"https://i.imgur.com/ekEgDL5.png","website":"plot_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/plot.py","tags":["python"]},{"title":"PID Operator","description":"PID controller","preview":"https://i.imgur.com/AEmoZ7k.gif","website":"pid_control_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/pid_control_op.py","tags":["python","control"]},{"title":"Obstacle Location Operator","description":"Obstacle location based on LIDAR and 2D bounding boxes","preview":"https://i.imgur.com/Aq33qy5.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/obstacle_location_op.py","tags":["python"]},{"title":"FOT Operator","description":"Waypoint generation based on current position and frenet optimal trajectory planner.","preview":"https://i.imgur.com/klQitzg.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/fot_op.py","tags":["python"]},{"title":"YOLOP Operator","description":"YOLOP lane and drivable area detection","preview":"https://i.imgur.com/I531NIT.gif","website":"yolop_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolop_op.py","tags":["cv","python"]},{"title":"MiDaS Operator","description":"MiDaS depth estimation","preview":"https://i.imgur.com/UrF9iPN.png","website":"midas_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/midas_op.py","tags":["depth_estimation","python"]},{"title":"Webcam Operator","description":"Webcam Operator","preview":"https://i.imgur.com/CC0IW3i.png","website":"webcam_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/webcam_op.py","tags":["python"]},{"title":"Strong Sort Operator","description":"Strong Sort Operator","preview":"https://i.imgur.com/ozO1y7l.gif","website":"strong_sort_op","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/strong_sort_op.py","tags":["cv","python"]}]');var b=o.t(g,2);const y=JSON.parse('[{"title":"Speech to Text","description":"Transform speech to text.","preview":"/img/whisper.png.avif","website":"stt","source":"https://github.com/dora-rs/dora/blob/main/examples/speech-to-text","tags":["audio","python"],"category":"Audio","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fspeech-to-text"},{"title":"Translation","description":"Translate audio in real time.","website":"translation","source":"https://github.com/dora-rs/dora/blob/main/examples/translation","tags":["audio","python"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Ftranslation","category":"Audio"},{"title":"Vision Language Model","description":"Use a VLM to understand images.","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"vlm","source":"https://github.com/dora-rs/dora/blob/main/examples/vlm","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fvlm","tags":["python","image"],"category":"Vision"},{"title":"YOLO","description":"Use YOLO to detect object within image.","preview":"https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-banner.avif","website":"yolo","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":["python","image"],"category":"Vision"},{"title":"Camera","description":"Simple webcam plot example","preview":"https://upload.wikimedia.org/wikipedia/commons/3/35/AdventWebcam.jpg","website":"webcam","source":"https://github.com/dora-rs/dora/blob/main/examples/camera","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcamera","tags":["python","image"],"category":"Vision"},{"title":"Piper RDT","description":"Piper RDT Pipeline","website":"piper","source":"https://github.com/dora-rs/dora/blob/main/examples/piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpiper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","tags":["python","image"],"category":"Training"},{"title":"LeRobot - Alexander Koch","description":"Piper RDT Pipeline","website":"lerobot","source":"https://raw.githubusercontent.com/dora-rs/dora-lerobot/refs/heads/main/README.md","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-lerobot","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","tags":["python","image"],"category":"Training"},{"title":"C Example","description":"Example with C node","website":"c-example","preview":"https://iq.direct/images/C-programming.png","source":"https://github.com/dora-rs/dora/blob/main/examples/c-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ Example","description":"Example with C++ node","website":"c++-example","preview":"https://repository-images.githubusercontent.com/124365799/7d888300-6a39-11ea-9025-fd5574f062c7","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-dataflow","tags":[],"category":"Tutorial"},{"title":"CMake Example","description":"Example using CMake","website":"cmake-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ-IsFXHxaLnZWam5sEJvnUZAzGMyGzXfOKMmIX9XeugcL45yTIuizNbaYi4Y-obbI14A&usqp=CAU","source":"https://github.com/dora-rs/dora/blob/main/examples/cmake-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcmake-dataflow","tags":[],"category":"Tutorial"},{"title":"CUDA Example","description":"Example using CUDA Zero Copy","website":"cuda-example","preview":"https://d29g4g2dyqv443.cloudfront.net/sites/default/files/akamai/ros-dp-nitros.gif","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Tutorial"},{"title":"Rust Example","description":"Example using Rust","website":"rust-example","preview":"https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-light.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-dataflow","tags":[],"category":"Tutorial"},{"title":"Python Example","description":"Example using Python","website":"python-example","preview":"https://upload.wikimedia.org/wikipedia/commons/f/f8/Python_logo_and_wordmark.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":[],"category":"Tutorial"},{"title":"Python ROS2 Example","description":"Example using Python ROS2","website":"python-ros2-example","preview":"https://www.aranacorp.com/wp-content/uploads/python-ros2.png","source":"https://github.com/dora-rs/dora/blob/main/examples/python-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"Rust ROS2 Example","description":"Example using Rust ROS2","website":"rust-ros2-example","preview":"https://robonomics.network/assets/static/cover.d57b2e8.268586f3596831daf0d2d0fa2c885458.jpg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ ROS2 Example","description":"Example using C++ ROS2","website":"c++-ros2-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSnC1cXYAAjFUjNAogVCAr8HrAmumbx9nEnhg&s","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"CPU Benchmark","description":"CPU Benchmark of dora-rs","website":"cpu-benchmark","preview":"https://github.com/user-attachments/assets/3285d183-7560-40e1-ac02-30fee0f120cb","source":"https://github.com/dora-rs/dora-benchmark/blob/main","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-benchmark","tags":[],"category":"Benchmark"},{"title":"GPU Benchmark","description":"GPU Benchmark of dora-rs","website":"gpu-benchmark","preview":"https://github.com/user-attachments/assets/d64370fc-b0ba-46af-be83-19d3c772ada6","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Benchmark"}]');var w=o.t(y,2);const v=JSON.parse('[{"title":"Whisper","description":"Transcribe audio to text","preview":"/img/whisper.png.avif","website":"whisper","github":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-distil-whisper","install":"- id: dora-distil-whisper\\n build: pip install dora-distil-whisper\\n path: dora-distil-whisper\\n inputs: \\n tick: /audio\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-distil-whisper","last_release":"https://img.shields.io/pypi/v/dora-distil-whisper","license":"https://img.shields.io/pypi/l/dora-distil-whisper","category":"Speech to Text"},{"title":"Qwenvl","description":"Vision Language Model","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"qwenvl","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-qwenvl","install":"- id: dora-qwenvl\\n build: pip install dora-qwenvl\\n path: dora-qwenvl\\n inputs: \\n text: /text\\n image: /image\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-qwenvl","tags":["python","image","text"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-qwenvl","last_release":"https://img.shields.io/pypi/v/dora-qwenvl","license":"https://img.shields.io/pypi/l/dora-qwenvl","category":"Vision Language Model"},{"title":"Silero VAD","description":"Silero Voice activity detection","preview":"https://user-images.githubusercontent.com/12515440/89997349-b3523080-dc94-11ea-9906-ca2e8bc50535.png","website":"silero","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-vad","install":"- id: dora-vad\\n build: pip install dora-vad\\n path: dora-vad\\n inputs: \\n tick: /audio\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-vad","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-vad","last_release":"https://img.shields.io/pypi/v/dora-vad","license":"https://img.shields.io/pypi/l/dora-vad","category":"Voice Activity Detection"},{"title":"Microphone","description":"Audio from microphone","author":"dora","website":"microphone","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8EPOj0PAu4yyERZg4ncm-vMgBqaU5lSP6_Q&s","downloads":"https://img.shields.io/pypi/dm/dora-microphone","install":"- id: dora-microphone\\n build: pip install dora-microphone\\n path: dora-microphone\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-microphone","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-microphone","last_release":"https://img.shields.io/pypi/v/dora-microphone","license":"https://img.shields.io/pypi/l/dora-microphone","category":"Peripheral"},{"title":"Rerun","description":"Visualization tool","author":"dora","website":"rerun","downloads":"https://img.shields.io/pypi/dm/dora-rerun","install":"- id: dora-rerun\\n build: pip install dora-rerun\\n path: dora-rerun\\n inputs: \\n image: /image\\n text: /text","preview":"https://user-images.githubusercontent.com/1148717/218141237-0442d2b5-ed22-42bf-9321-10af1b894507.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rerun","tags":["rust","text","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rerun","last_release":"https://img.shields.io/pypi/v/dora-rerun","license":"https://img.shields.io/pypi/l/dora-rerun","category":"Visualization"},{"title":"Video Capture","description":"Image stream from Camera","author":"dora","website":"opencv-video-capture","install":"- id: opencv-video-capture\\n build: pip install opencv-video-capture\\n path: opencv-video-capture\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image","downloads":"https://img.shields.io/pypi/dm/opencv-video-capture","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-video-capture","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-video-capture","last_release":"https://img.shields.io/pypi/v/opencv-video-capture","license":"https://img.shields.io/pypi/l/opencv-video-capture","tags":["python","image"],"category":"Camera"},{"title":"Yolov8","description":"Object detection","author":"dora","website":"yolo","install":"- id: dora-yolo\\n build: pip install dora-yolo\\n path: dora-yolo\\n inputs: \\n image: /image\\n outputs: \\n - bbox","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-yolo","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-yolo","last_release":"https://img.shields.io/pypi/v/dora-yolo","license":"https://img.shields.io/pypi/l/dora-yolo","tags":["python","image"],"category":"Object Detection"},{"title":"Plot","description":"Simple OpenCV plot visualization","author":"dora","website":"opencv-plot","install":"- id: opencv-plot\\n build: pip install opencv-plot\\n path: opencv-plot\\n inputs: \\n image: /image\\n text: /text","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-plot","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-plot","last_release":"https://img.shields.io/pypi/v/opencv-plot","license":"https://img.shields.io/pypi/l/opencv-plot","tags":["python","image","text"],"category":"Visualization"},{"title":"PyRealsense","description":"Image and depth from Realsense","author":"dora","website":"pyrealsense","install":"- id: dora-pyrealsense\\n build: pip install dora-pyrealsense\\n path: dora-pyrealsense\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth","downloads":"https://img.shields.io/pypi/dm/dora-pyrealsense","preview":"https://user-images.githubusercontent.com/41145062/193884336-c30397be-2cac-45da-ba34-07e7db9843e8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyrealsense","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyrealsense","last_release":"https://img.shields.io/pypi/v/dora-pyrealsense","license":"https://img.shields.io/pypi/l/dora-pyrealsense","tags":["python","image","depth"],"category":"Camera"},{"title":"PyOrbbeckSDK","description":"Image and depth from Orbbeck Camera","author":"dora","website":"pyorbbecsdk","install":"- id: dora-pyorbbecksdk\\n build: pip install dora-pyorbbecksdk\\n path: dora-pyorbbecksdk\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth\\n - image_depth","downloads":"https://img.shields.io/pypi/dm/dora-pyorbbecksdk","preview":"https://new-orbbec3d-s3.s3.amazonaws.com/wp-content/uploads/2024/06/03120334/\u53f345\u5ea6-e1717416268437-300x153.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyorbbecksdk","tags":["python","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyorbbecksdk","last_release":"https://img.shields.io/pypi/v/dora-pyorbbecksdk","license":"https://img.shields.io/pypi/l/dora-pyorbbecksdk","category":"Camera"},{"title":"Keyboard","description":"Keyboard char listener","author":"dora","website":"keyboard","install":"- id: dora-keyboard\\n build: pip install dora-keyboard\\n path: dora-keyboard\\n inputs: \\n tick: dora/timer/millis/1000\\n outputs: \\n - char","downloads":"https://img.shields.io/pypi/dm/dora-keyboard","preview":"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/LenovoKeyboard.jpg/220px-LenovoKeyboard.jpg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-keyboard","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-keyboard","last_release":"https://img.shields.io/pypi/v/dora-keyboard","license":"https://img.shields.io/pypi/l/dora-keyboard","tags":["python","text"],"category":"Peripheral"},{"title":"Agilex - Piper","description":"Agilex arm client","author":"dora","website":"piper","install":"- id: dora-piper\\n build: pip install dora-piper\\n path: dora-piper\\n inputs: \\n tick: dora/timer/millis/20\\n joint_action: /jointstate\\n outputs: \\n - jointstate","downloads":"https://img.shields.io/pypi/dm/dora-piper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-piper","last_release":"https://img.shields.io/pypi/v/dora-piper","license":"https://img.shields.io/pypi/l/dora-piper","tags":["python"],"category":"Arm"},{"title":"Opus MT","description":"Translate text between language","author":"dora","website":"opus","install":"- id: dora-opus\\n build: pip install dora-opus\\n path: dora-opus\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","downloads":"https://img.shields.io/pypi/dm/dora-opus","preview":"https://github.com/Helsinki-NLP/Opus-MT/raw/master/img/opus_mt.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-opus","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-opus","last_release":"https://img.shields.io/pypi/v/dora-opus","license":"https://img.shields.io/pypi/l/dora-opus","tags":["python","text"],"category":"Translation"},{"title":"Llama Factory Recorder","description":"Record data to train LLM and VLM","author":"dora","website":"llama-factory-recorder","install":"- id: llama-factory-recorder\\n build: pip install llama-factory-recorder\\n path: llama-factory-recorder\\n inputs: \\n image: /image\\n text: /text\\n ground_truth: /text\\n outputs: \\n - text","downloads":"https://img.shields.io/pypi/dm/llama-factory-recorder","preview":"https://github.com/hiyouga/LLaMA-Factory/blob/main/assets/logo.png?raw=true","source":"https://github.com/dora-rs/dora/blob/main/node-hub/llama-factory-recorder","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fllama-factory-recorder","last_release":"https://img.shields.io/pypi/v/llama-factory-recorder","license":"https://img.shields.io/pypi/l/llama-factory-recorder","tags":["python","image","text"],"category":"Recorder"},{"title":"RDT-1B","description":"Infer policy using Robotic Diffusion Transformer","author":"dora","website":"rdt","install":"- id: dora-rdt-1b\\n build: pip install dora-rdt-1b\\n path: dora-rdt-1b\\n inputs: \\n image: /image\\n jointstate: /jointstate\\n outputs: \\n - action","downloads":"https://img.shields.io/pypi/dm/dora-rdt-1b","preview":"https://github.com/thu-ml/RoboticsDiffusionTransformer/raw/main/assets/head.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rdt-1b","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rdt-1b","last_release":"https://img.shields.io/pypi/v/dora-rdt-1b","license":"https://img.shields.io/pypi/l/dora-rdt-1b","tags":["python","image","text"],"category":"Vision Language Action"},{"title":"Dynamixel","description":"Dynamixel Client","author":"Enzo Levan","website":"dynamixel","preview":"https://robots.ros.org/assets/img/robots/dynamixel/dynamixel.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dynamixel-client","tags":["python"],"category":"Actuator"},{"title":"Feetech","description":"Feetech Client","author":"Enzo Levan","website":"feetech","preview":"https://media.licdn.com/dms/image/v2/C5612AQGpeiwwIPDqaw/article-cover_image-shrink_720_1280/article-cover_image-shrink_720_1280/0/1647414552058?e=2147483647&v=beta&t=QoHYcvm7pla6ptYtg3daKPAGRRctKGEkIGkBrGyE25Y","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/feetech-client","tags":["python"],"category":"Actuator"},{"title":"Mujoco","description":"Mujoco Simulator","author":"Enzo Levan","website":"mujoco","preview":"https://github.com/google-deepmind/mujoco/raw/main/banner.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/mujoco-client","tags":["python"],"category":"Simulator"},{"title":"Lebai - LM3","description":"Lebai client","author":"dora","website":"lebai","preview":"https://l-www.lebai.ltd/2015/07/1-495x400.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lebai-client","tags":["python"],"category":"Arm"},{"title":"Alex Koch - Low Cost Robot","description":"Alex Koch - Low Cost Robot Client","author":"dora","website":"alex-koch-low-cost-robot","preview":"https://github.com/AlexanderKoch-Koch/low_cost_robot/raw/main/pictures/robot_portait.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/alexk-lcr","tags":["python"],"category":"Arm"},{"title":"Trossen - Aloha","description":"Aloha client","author":"dora","website":"aloha","preview":"https://static.wixstatic.com/media/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg/v1/fill/w_1000,h_659,al_c,q_85,usm_0.66_1.00_0.01/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/aloha","tags":["python"],"category":"Robot"},{"title":"Pollen - Reachy 2","description":"Reachy 2 client","author":"dora","website":"reachy2","preview":"https://www.lejournaldesentreprises.com/sites/lejournaldesentreprises.com/files/styles/landscape_web_lg_1x/public/2024-11/Reachy-2-sait-reprer-un-objet-le-saisir-et-le-m-15512511.jpeg?itok=syrnHhWx","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/reachy","tags":["python"],"category":"Robot"},{"title":"Carla","description":"Carla Simulator","author":"dora","website":"carla","preview":"https://media.licdn.com/dms/image/v2/D4D1BAQHyb4EFail-wQ/company-background_10000/company-background_10000/0/1663774857825/carla_simulator_cover?e=2147483647&v=beta&t=AmftWPQMtfni1t_RXUvqqkQJqxKK_I54BoHpLLSwjWE","source":"https://github.com/dora-rs/dora-drives","tags":["python"],"category":"Simulator"},{"title":"Pollen - Reachy 1","description":"Reachy 1 Client","author":"dora","website":"reachy1","install":"- id: dora-reachy1\\n build: pip install dora-reachy1\\n path: dora-reachy1","preview":"https://www.aquitaineonline.com/images/stories/Economie_Industrie_2021/Reachy_01.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dora-reachy1","tags":["python"],"category":"Robot"},{"title":"DJI - Robomaster S1","description":"Robomaster Client","author":"dora","website":"robomaster-s1","preview":"https://m.media-amazon.com/images/I/61K2UXjfHwL.jpg","source":"https://huggingface.co/datasets/dora-rs/dora-robomaster","tags":["python"],"category":"Chassis"},{"title":"Agilex - UGV","description":"Robomaster Client","author":"dora","website":"robomaster-s1","downloads":"https://img.shields.io/pypi/dm/dora-ugv","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvTwJ589Zudgva9TIQ79ddJ8wHUq2_jmrUZg&s","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-ugv","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-ugv","last_release":"https://img.shields.io/pypi/v/dora-ugv","license":"https://img.shields.io/pypi/l/dora-ugv","tags":["python"],"category":"Chassis"},{"title":"Dora Kit Car","description":"Open Source Chassis","author":"dora","website":"dora-kit-car","downloads":"https://img.shields.io/pypi/dm/dora-kit-car","preview":"https://github.com/RuPingCen/mick_robot_chassis/raw/master/README.assets/fengmian.gif","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-kit-car","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-kit-car","last_release":"https://img.shields.io/pypi/v/dora-kit-car","license":"https://img.shields.io/pypi/l/dora-kit-car","tags":["python"],"category":"Chassis"},{"title":"ArgosTranslate","description":"Open Source translation engine","author":"dora","website":"argotranslate","downloads":"https://img.shields.io/pypi/dm/dora-argotranslate","install":"- id: dora-argotranslate\\n build: pip install dora-argotranslate\\n path: dora-argotranslate\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","preview":"https://avatars.githubusercontent.com/u/48267258?v=4","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-argotranslate","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-argotranslate","last_release":"https://img.shields.io/pypi/v/dora-argotranslate","license":"https://img.shields.io/pypi/l/dora-argotranslate","tags":["python"],"category":"Translation"},{"title":"InternVL","description":"InternVL is a vision language model","author":"dora","website":"internvl","downloads":"https://img.shields.io/pypi/dm/dora-internvl","preview":"https://private-user-images.githubusercontent.com/23737120/379689418-930e6814-8a9f-43e1-a284-118a5732daa4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYzNDcwODEsIm5iZiI6MTczNjM0Njc4MSwicGF0aCI6Ii8yMzczNzEyMC8zNzk2ODk0MTgtOTMwZTY4MTQtOGE5Zi00M2UxLWEyODQtMTE4YTU3MzJkYWE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA4VDE0MzMwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3YTUyM2UyMDc5ZmMxNjk5NWZmNzg4ZjgxN2VkNzIyOTFmYjc2OGJiZGJlOWQ1Y2Q4NWU2OTJhYmRjMzZhZjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uiWkdjPEgeUJkiCVNii9Huh4M1ykJ2Cm_FVcTDcldYs","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-internvl","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-internvl","last_release":"https://img.shields.io/pypi/v/dora-internvl","license":"https://img.shields.io/pypi/l/dora-internvl","tags":["python"],"category":"Vision Language Model"},{"title":"LeRobot Recorder","description":"LeRobot Recorder helper","author":"dora","website":"lerobot-dashboard","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lerobot-dashboard","tags":["python"],"category":"Recorder"},{"title":"Gymnasium","description":"Experimental OpenAI Gymnasium bridge","author":"dora","website":"gymnasium","preview":"https://raw.githubusercontent.com/Farama-Foundation/Gymnasium/main/gymnasium-text.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/gym_dora","tags":["python"],"category":"Simulator"}]');var x=o.t(v,2);const f=["Camera","Peripheral","Actuator","Chassis","Arm","Robot","Voice Activity Detection","Speech to Text","Object Detection","Vision Language Model","Large Language Model","Vision Language Action","Translation","Text to Speech","Recorder","Visualization","Simulator"],_=["Audio","Vision","Training","Tutorial","Benchmark"],j={image:{label:(0,r.T)({id:"showcase.tag.image.tag",message:"image"}),description:(0,r.T)({message:"Computer vision related nodes!",id:"showcase.tag.image.description"}),color:"#39ca30"},python:{label:(0,r.T)({id:"showcase.tag.python.tag",message:"python"}),description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.python.description"}),color:"#dfd545"},rust:{label:"rust",description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.rust.description"}),color:"#333e2e"},control:{label:(0,r.T)({id:"showcase.tag.control.tag",message:"control"}),description:(0,r.T)({message:"Beautiful Docusaurus sites, polished and standing out from the initial template!",id:"showcase.tag.control.description"}),color:"#a44fb7"},depth:{label:(0,r.T)({id:"showcase.tag.depth.tag",message:"depth"}),description:(0,r.T)({message:"Translated Docusaurus sites using the internationalization support with more than 1 locale.",id:"showcase.tag.depth.description"}),color:"#127f82"},audio:{label:(0,r.T)({message:"audio"}),description:(0,r.T)({message:"Docusaurus sites using the versioning feature of the docs plugin to manage multiple versions.",id:"showcase.tag.audio.description"}),color:"#fe6829"},text:{label:(0,r.T)({message:"text"}),description:(0,r.T)({message:"Very large Docusaurus sites, including many more pages than the average!",id:"showcase.tag.large.description"}),color:"#8c2f00"}},k=Object.keys(j),C=b,E=w,L=x;!function(){let t=C.default;t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite")))}();const A=function(){let t=E.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();const N=function(){let t=L.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();var T=o(51107);const O="checkboxLabel_0lFL",F="tags";function R(t){return new URLSearchParams(t).getAll(F)}function S(t,e){let{id:o,icon:a,label:i,tag:r,...l}=t;const d=(0,n.zy)(),c=(0,n.W6)(),[h,m]=(0,s.useState)(!1);(0,s.useEffect)((()=>{const t=R(d.search);m(t.includes(r))}),[r,d]);const u=(0,s.useCallback)((()=>{const t=function(t,e){const o=t.indexOf(e);if(-1===o)return t.concat(e);const s=[...t];return s.splice(o,1),s}(R(d.search),r),e=function(t,e){const o=new URLSearchParams(t);return o.delete(F),e.forEach((t=>o.append(F,t))),o.toString()}(d.search,t);c.push({...d,search:e,state:K()})}),[r,d,c]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("input",{type:"checkbox",id:o,className:"screen-reader-only",onKeyDown:t=>{"Enter"===t.key&&u()},onFocus:t=>{t.relatedTarget&&t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("focus"))},onBlur:t=>{t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("blur"))},onChange:u,checked:h,...l}),(0,p.jsxs)("label",{ref:e,htmlFor:o,className:O,children:[i,a]})]})}const I=s.forwardRef(S),D={checkboxLabel:"checkboxLabel_tOkT"},M="operator";function P(t){return new URLSearchParams(t).get(M)??"OR"}function U(){const t="showcase_filter_toggle",e=(0,n.zy)(),o=(0,n.W6)(),[i,r]=(0,s.useState)(!1);(0,s.useEffect)((()=>{r("AND"===P(e.search))}),[e]);const l=(0,s.useCallback)((()=>{r((t=>!t));const t=new URLSearchParams(e.search);t.delete(M),i||t.append(M,"AND"),o.push({...e,search:t.toString(),state:K()})}),[i,e,o]);return(0,p.jsxs)("div",{children:[(0,p.jsx)("input",{type:"checkbox",id:t,className:"screen-reader-only","aria-label":"Toggle between or and and for the tags you selected",onChange:l,onKeyDown:t=>{"Enter"===t.key&&l()},checked:i}),(0,p.jsxs)("label",{htmlFor:t,className:(0,a.A)(D.checkboxLabel,"shadow--md"),children:[(0,p.jsx)("span",{className:D.checkboxLabelOr,children:"OR"}),(0,p.jsx)("span",{className:D.checkboxLabelAnd,children:"AND"})]})]})}var V=o(40961),z=o(50991);const G={tooltip:"tooltip_vy6_",tooltipArrow:"tooltipArrow_lQYZ"};function B(t){let{children:e,id:o,anchorEl:a,text:i}=t;const[r,n]=(0,s.useState)(!1),[l,d]=(0,s.useState)(null),[c,h]=(0,s.useState)(null),[m,u]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),{styles:y,attributes:w}=(0,z.E)(l,c,{modifiers:[{name:"arrow",options:{element:m}},{name:"offset",options:{offset:[0,8]}}]}),v=(0,s.useRef)(null),x=`${o}_tooltip`;return(0,s.useEffect)((()=>{b(a?"string"==typeof a?document.querySelector(a):a:document.body)}),[g,a]),(0,s.useEffect)((()=>{const t=["mouseenter","focus"],e=["mouseleave","blur"],o=()=>{""!==i&&(l?.removeAttribute("title"),v.current=window.setTimeout((()=>{n(!0)}),400))},s=()=>{clearInterval(v.current),n(!1)};return l&&(t.forEach((t=>{l.addEventListener(t,o)})),e.forEach((t=>{l.addEventListener(t,s)}))),()=>{l&&(t.forEach((t=>{l.removeEventListener(t,o)})),e.forEach((t=>{l.removeEventListener(t,s)})))}}),[l,i]),(0,p.jsxs)(p.Fragment,{children:[s.cloneElement(e,{ref:d,"aria-describedby":r?x:void 0}),g?V.createPortal(r&&(0,p.jsxs)("div",{id:x,role:"tooltip",ref:h,className:G.tooltip,style:y.popper,...w.popper,children:[i,(0,p.jsx)("span",{ref:u,className:G.tooltipArrow,style:y.arrow})]}),g):g]})}const W={showcaseCardImage:"showcaseCardImage_RonU",showcaseCardHeader:"showcaseCardHeader_DBrh",showcaseCardHeaderNoImage:"showcaseCardHeaderNoImage_I3oL",showcaseCardTitle:"showcaseCardTitle_c4K_",svgIconFavorite:"svgIconFavorite_eNhx",showcaseCardSrcBtn:"showcaseCardSrcBtn_zC6u",showcaseCardBody:"showcaseCardBody_Uq33",cardFooter:"cardFooter_jnMp",tag:"tag_rgoW",textLabel:"textLabel_Um7W",colorLabel:"colorLabel_wSaw"};var Y=o(21432);const q=s.forwardRef(((t,e)=>{let{label:o,color:s,description:a}=t;return(0,p.jsxs)("li",{ref:e,className:W.tag,title:a,children:[(0,p.jsx)("span",{className:W.textLabel,children:o.toLowerCase()}),(0,p.jsx)("span",{className:W.colorLabel,style:{backgroundColor:s}})]})}));function J(t){let{tags:e}=t;const o=u(e.map((t=>({tag:t,...j[t]}))),(t=>k.indexOf(t.tag)));return(0,p.jsx)(p.Fragment,{children:o.map(((t,e)=>{const o=`showcase_card_tag_${t.tag}`;return(0,p.jsx)(B,{text:t.description,anchorEl:"#__docusaurus",id:o,children:(0,p.jsx)(q,{...t},e)},e)}))})}function Z(t){let{user:e}=t;!function(t){t.preview}(e);const o=e.source;return(0,p.jsxs)("li",{className:"card shadow--md",children:[(0,p.jsxs)("div",{className:(0,a.A)("card__image",W.showcaseCardImage),children:[e.preview&&(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,style:{height:"150px",display:"flex"},children:(0,p.jsx)("img",{src:e.preview,style:{margin:"auto"},alt:" "})}),null==e.preview&&(0,p.jsx)("h2",{className:W.showcaseCardHeaderNoImage,children:e.title})]}),(0,p.jsxs)("div",{className:"card__body",children:[(0,p.jsxs)("div",{className:(0,a.A)(W.showcaseCardHeader),children:[(0,p.jsxs)(T.A,{as:"h4",className:W.showcaseCardTitle,children:[(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,children:e.title}),e.author&&(0,p.jsxs)("em",{style:{color:"grey"},children:[" by ",e.author]})]}),e.tags.includes("favorite")&&(0,p.jsx)(m,{svgClass:W.svgIconFavorite,size:"small"}),e.source&&(0,p.jsx)(d.A,{href:e.source,className:(0,a.A)("button button--secondary button--sm",W.showcaseCardSrcBtn),children:(0,p.jsx)("img",{src:"/img/github.svg",width:"20px"})})]}),(0,p.jsx)("p",{className:W.showcaseCardBody,children:e.description}),e.install&&(0,p.jsx)("div",{children:(0,p.jsxs)("details",{children:[(0,p.jsx)("summary",{children:(0,p.jsx)("em",{children:"Try it with..."})}),(0,p.jsx)(Y.A,{language:"yaml",children:e.install})]})})]}),(0,p.jsxs)("ul",{className:(0,a.A)("card__footer",W.cardFooter),children:[(0,p.jsxs)("div",{children:[e.downloads&&(0,p.jsx)("img",{className:"margin-right--sm",src:e.downloads}),e.last_commit&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last commit",src:e.last_commit}),e.last_release&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last release",src:e.last_release}),e.license&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub license",src:e.license})]}),(0,p.jsx)("div",{children:(0,p.jsx)(J,{tags:e.tags})})]})]},e.title)}const Q=s.memo(Z),X={filterCheckbox:"filterCheckbox_Feyr",checkboxList:"checkboxList_jTdS",checkboxListItem:"checkboxListItem_dFB0",searchContainer:"searchContainer_s3C6",showcaseList:"showcaseList_CRXj",showcaseFavorite:"showcaseFavorite_XwQD",showcaseFavoriteHeader:"showcaseFavoriteHeader_o0j3",svgIconFavoriteXs:"svgIconFavoriteXs_kiRS",svgIconFavorite:"svgIconFavorite_QxXa"},H="https://github.com/dora-rs/dora-rs.github.io/blob/main/src/data/nodes.json";function K(){if(i.A.canUseDOM)return{scrollTopPosition:window.scrollY,focusedElementId:document.activeElement?.id}}const $="name";function tt(t){return new URLSearchParams(t).get($)}function et(t){const e=(0,n.zy)(),[o,a]=(0,s.useState)("OR"),[i,r]=(0,s.useState)([]),[l,d]=(0,s.useState)(null);return(0,s.useEffect)((()=>{r(R(e.search)),a(P(e.search)),d(tt(e.search)),function(t){const{scrollTopPosition:e,focusedElementId:o}=t??{scrollTopPosition:0,focusedElementId:void 0};document.getElementById(o)?.focus(),window.scrollTo({top:e})}(e.state)}),[e]),(0,s.useMemo)((()=>function(t,e,o,s){return s&&(t=t.filter((t=>t.title.toLowerCase().includes(s.toLowerCase())))),0===e.length?t:t.filter((t=>0!==t.tags.length&&("AND"===o?e.every((e=>t.tags.includes(e))):e.some((e=>t.tags.includes(e))))))}(t,i,o,l)),[i,o,l])}function ot(t){let{text:e,url:o}=t;return(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--lg text--center",children:(0,p.jsx)(d.A,{className:"button button--primary",to:o,children:e})})}function st(t){let{sortedExamples:e}=t;const o=et(e),s=function(){const{selectMessage:t}=(0,l.W)();return e=>t(e,(0,r.T)({id:"showcase.filters.resultCount",description:'Pluralized label for the number of sites found on the showcase. Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',message:"1 site|{sitesCount} sites"},{sitesCount:e}))}();return(0,p.jsxs)("section",{className:"container margin-top--l margin-bottom--lg",children:[(0,p.jsxs)("div",{className:(0,a.A)("margin-bottom--sm",X.filterCheckbox),children:[(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.filters.title",children:"Filters"})}),(0,p.jsx)("span",{children:s(o.length)})]}),(0,p.jsx)(U,{})]}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.checkboxList),children:k.map(((t,e)=>{const{label:o,description:s,color:a}=j[t],i=`showcase_checkbox_id_${t}`;return(0,p.jsx)("li",{className:X.checkboxListItem,children:(0,p.jsx)(B,{id:i,text:s,anchorEl:"#__docusaurus",children:(0,p.jsx)(I,{tag:t,id:i,label:o,icon:"favorite"===t?(0,p.jsx)(m,{svgClass:X.svgIconFavoriteXs}):(0,p.jsx)("span",{style:{backgroundColor:a,width:10,height:10,borderRadius:"50%",marginLeft:8}})})})},e)}))})]})}function at(){const t=(0,n.W6)(),e=(0,n.zy)(),[o,a]=(0,s.useState)(null);return(0,s.useEffect)((()=>{a(tt(e.search))}),[e]),(0,p.jsx)("div",{className:X.searchContainer,children:(0,p.jsx)("input",{id:"searchbar",placeholder:(0,r.T)({message:"Search for site name...",id:"showcase.searchBar.placeholder"}),value:o??void 0,onInput:o=>{a(o.currentTarget.value);const s=new URLSearchParams(e.search);s.delete($),o.currentTarget.value&&s.set($,o.currentTarget.value),t.push({...e,search:s.toString(),state:K()}),setTimeout((()=>{document.getElementById("searchbar")?.focus()}),0)}})})}function it(t){let{sortedExamples:e,Categories:o}=t;const s=et(e);return 0===s.length?(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container padding-vert--md text--center",children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.usersList.noResult",children:"No result"})}),(0,p.jsx)(at,{})]})}):(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container",children:[(0,p.jsx)("div",{className:(0,a.A)("margin-bottom--md",X.showcaseFavoriteHeader),children:(0,p.jsx)(at,{})}),(0,p.jsx)("div",{children:o.map((t=>{let e=s.filter((e=>e.category==t));return 0===e.length?null:(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:t}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.showcaseList),children:e.map((t=>(0,p.jsx)(Q,{user:t},t.title)))})]})}))})]})})}function rt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(ot,{url:H,text:"Showcase your nodes \ud83d\udd25"}),(0,p.jsx)(st,{sortedExamples:N}),(0,p.jsx)(it,{sortedExamples:N,Categories:f})]})}function nt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(ot,{url:H,text:"Showcase your examples \ud83d\udd25"}),(0,p.jsx)(st,{sortedExamples:A}),(0,p.jsx)(it,{sortedExamples:A,Categories:_})]})}}}]); \ No newline at end of file diff --git a/assets/js/32b584a3.97b27bd2.js b/assets/js/32b584a3.ee6d4c10.js similarity index 99% rename from assets/js/32b584a3.97b27bd2.js rename to assets/js/32b584a3.ee6d4c10.js index e316ea02..bff695d0 100644 --- a/assets/js/32b584a3.97b27bd2.js +++ b/assets/js/32b584a3.ee6d4c10.js @@ -1 +1 @@ -"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[5159],{81819:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>o,toc:()=>c});var r=t(74848),a=t(28453);const s={authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},i=void 0,o={permalink:"/blog/rust-python",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/rust-python.md",source:"@site/blog/rust-python.md",title:"Rust-Python FFI",description:"Rust-Python FFI.",date:"2025-01-11T14:26:10.000Z",tags:[],readingTime:10.8,hasTruncateMarker:!1,authors:[{name:"Haixuan Xavier Tao",title:"Maintainer of dora-rs",url:"https://github.com/haixuantao",imageURL:"https://github.com/haixuantao.png",key:"haixuan"}],frontMatter:{authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},unlisted:!1},l={authorsImageUrls:[void 0]},c=[{value:"Foreign Function Interface",id:"foreign-function-interface",level:2},{value:"Interfacing Arrays",id:"interfacing-arrays",level:2},{value:"Implementation 1: Default",id:"implementation-1-default",level:3},{value:"> Calling create_list for a very large list like: value = [1] * 100_000_000 is going to return in 2.27s \ud83d\ude9c",id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",level:4},{value:"Implementation 2: PyBytes",id:"implementation-2-pybytes",level:3},{value:"> For the same list input, create_list_bytes returns in 78 milliseconds. That's 30x better \ud83d\udc0e",id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",level:4},{value:"Implementation 3: Apache Arrow",id:"implementation-3-apache-arrow",level:3},{value:"> Same list returns in 33 milliseconds . That's 2x better than PyBytes \ud83d\udc0e\ud83d\udc0e",id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",level:4},{value:"Debugging",id:"debugging",level:2},{value:".unwrap()",id:"unwrap",level:3},{value:"> Example error:",id:"-example-error",level:4},{value:"eyre",id:"eyre",level:3},{value:"> Same error as above but with eyre which gives a better looking error message:",id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",level:4},{value:"Python traceback with eyre",id:"python-traceback-with-eyre",level:3},{value:"> Example error with no custom traceback:",id:"-example-error-with-no-custom-traceback",level:4},{value:"> Better errors with custom traceback:",id:"-better-errors-with-custom-traceback",level:4},{value:"Memory management",id:"memory-management",level:2},{value:"> Calling this function will consume 440MB of memory. \ud83d\udc4e",id:"-calling-this-function-will-consume-440mb-of-memory--1",level:4},{value:"> Calling this function will consume 80MB of memory. :thumbsup:",id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",level:4},{value:"Race condition",id:"race-condition",level:2},{value:"> This threaded print was printed after 10.0s. \ud83d\ude22",id:"-this-threaded-print-was-printed-after-100s-cry",level:4},{value:"> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. \ud83d\ude04",id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",level:4},{value:"Tracing",id:"tracing",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:"Writing a rust library that is usable in multiple languages is not easy..."}),"\n",(0,r.jsxs)(n.p,{children:["This blogpost recollects things I have encountered while building ",(0,r.jsx)(n.a,{href:"https://github.com/webonnx/wonnx",children:"wonnx"})," and ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"}),". I am going to use Rust-Python FFI through ",(0,r.jsx)(n.code,{children:"pyo3"})," as an example. You can then extrapolate those issues to other languages FFI."]}),"\n",(0,r.jsx)(n.h2,{id:"foreign-function-interface",children:"Foreign Function Interface"}),"\n",(0,r.jsx)(n.p,{children:"A foreign function interface (FFI) is an interface used to share data from different languages."}),"\n",(0,r.jsxs)(n.p,{children:["By default, python might not know what a Rust ",(0,r.jsx)(n.code,{children:"u16"})," is, so an interface is needed to make the two languages communicate."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://hackmd.io/_uploads/S1qiK8hRh.png",alt:""})}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Image from ",(0,r.jsx)(n.a,{href:"https://hacks.mozilla.org/2019/08/webassembly-interface-types/",children:"WebAssembly Interface Types: Interoperate with All the Things!"})]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"Building interfaces is not easy. Most of the time, we have to use the C-ABI to build our FFI as it is the common denominator between languages."}),"\n",(0,r.jsx)(n.p,{children:"Thankfully, there are FFI libraries that create interfaces for us and we can just focus on the important stuff such as the logic, algorithm, and so on."}),"\n",(0,r.jsx)(n.p,{children:"However, those FFI libraries might have limitations. This is what we're going to discuss."}),"\n",(0,r.jsxs)(n.p,{children:["One example of such FFI library is ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})}),". ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})})," is one of the most used Rust-Python binding and creates FFIs for you. All we have to do is wrap our function with a ",(0,r.jsx)(n.code,{children:"#[pyfunction]"})," and that will make it usable in Python."]}),"\n",(0,r.jsx)(n.h2,{id:"interfacing-arrays",children:"Interfacing Arrays"}),"\n",(0,r.jsxs)(n.p,{children:["In this blog post, I'm going to build a toy Rust-Python project with ",(0,r.jsx)(n.code,{children:"pyo3"})," to illustrate the issues I have faced."]}),"\n",(0,r.jsxs)(n.p,{children:["You can try this blogpost at home by forking the ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi",children:"blogpost repository"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"If you want to start from scratch, you can create a new project with:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"mkdir blogpost_ffi\nmaturin init # pyo3\n"})}),"\n",(0,r.jsx)(n.p,{children:"The default project will looks like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"use pyo3::prelude::*;\n\n/// Formats the sum of two numbers as string.\n#[pyfunction]\nfn sum_as_string(a: usize, b: usize) -> PyResult {\n Ok((a + b).to_string())\n}\n\n/// A Python module implemented in Rust. The name of this function must match\n/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to\n/// import the module.\n#[pymodule]\nfn string_sum(_py: Python<'_>, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"We can call the function as follows:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'maturin develop\npython -c "import blogpost_ffi; print(blogpost_ffi.sum_as_string(1,1))"\n# Return: "2" \n'})}),"\n",(0,r.jsxs)(n.p,{children:["In the above example, ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to create FFIs to make Python integer interpretable as a Rust ",(0,r.jsx)(n.code,{children:"usize"})," without additional work."]}),"\n",(0,r.jsx)(n.p,{children:"However, automatically interpreted types might not be the most optimized implementation."}),"\n",(0,r.jsx)(n.h3,{id:"implementation-1-default",children:"Implementation 1: Default"}),"\n",(0,r.jsx)(n.p,{children:"Let's imagine that, we want to play with arrays, we want to receive an array input and return an array output between Rust and Python.\nA default inplementation, would look like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list(a: Vec<&PyAny>) -> PyResult> {\n Ok(a)\n}\n\n#[pymodule]\nfn blogpost_ffi(_py: Python, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n m.add_function(wrap_pyfunction!(create_list, m)?)?;\n Ok(())\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",children:["> Calling ",(0,r.jsx)(n.code,{children:"create_list"})," for a very large list like: ",(0,r.jsx)(n.code,{children:"value = [1] * 100_000_000"})," is going to return in ",(0,r.jsx)(n.strong,{children:"2.27s"})," ","\ud83d\ude9c"]}),"\n",(0,r.jsx)(n.p,{children:"That's quite slow... The reason being is that this list is going to be interpret one element at a time in a loop. We can do better by trying to use all elements at the same time."}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Check ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi/blob/main/test_script.py",children:"test_script.py"})," for details on how the function is called."]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"implementation-2-pybytes",children:"Implementation 2: PyBytes"}),"\n",(0,r.jsxs)(n.p,{children:["Let's imagine that our array is a C-contiguous array that can be represented as a ",(0,r.jsx)(n.a,{href:"https://docs.python.org/3/library/stdtypes.html?highlight=bytes#bytes",children:(0,r.jsx)(n.code,{children:"PyBytes"})}),". The code can be optimized by casting the inputs and output as a ",(0,r.jsx)(n.code,{children:"PyBytes"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_bytes<'a>(py: Python<'a>, a: &'a PyBytes) -> PyResult<&'a PyBytes> {\n let s = a.as_bytes();\n\n let output = PyBytes::new_with(py, s.len(), |bytes| {\n bytes.copy_from_slice(s);\n Ok(())\n })?;\n Ok(output)\n}\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",children:["> For the same list input, ",(0,r.jsx)(n.code,{children:"create_list_bytes"})," returns in ",(0,r.jsx)(n.strong,{children:"78 milliseconds"}),". That's ",(0,r.jsx)(n.strong,{children:"30x"})," better ","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"The speedup comes from the possibility to copy the memory range instead of iterating each element and to read without copying."}),"\n",(0,r.jsx)(n.p,{children:"Now the issue is that:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," is only available in Python meaning that if we plan to have other languages, we will have to replicate this for each language."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," might also probably need to be reconverted into other useful types."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," needs a copy to be created."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["We can try to solve this with ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"}),"."]}),"\n",(0,r.jsxs)(n.h3,{id:"implementation-3-apache-arrow",children:["Implementation 3: ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"})]}),"\n",(0,r.jsx)(n.p,{children:"Apache Arrow is a universal memory format available in many languages."}),"\n",(0,r.jsxs)(n.p,{children:["The same function in ",(0,r.jsx)(n.code,{children:"arrow"})," would look like this:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_arrow(py: Python, a: &PyAny) -> PyResult> {\n let arraydata = arrow::array::ArrayData::from_pyarrow(a).unwrap();\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).unwrap();\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .unwrap();\n\n output.to_pyarrow(py)\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",children:["> Same list returns in ",(0,r.jsx)(n.strong,{children:"33 milliseconds"})," . That's ",(0,r.jsx)(n.strong,{children:"2x"})," better than ",(0,r.jsx)(n.code,{children:"PyBytes"})," ","\ud83d\udc0e","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"This is due to having zero copy when sending back the result. The zero-copying is safe because we are reference-counting the array. The array will be deallocating once all reference has been removed."}),"\n",(0,r.jsxs)(n.p,{children:["The benefits of ",(0,r.jsx)(n.code,{children:"arrow"})," is:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"to make zero-copy achievable, scaling better with bigger data."}),"\n",(0,r.jsx)(n.li,{children:"being reusable in other languages. We only have to replace the last line of the function with the export to the other languages."}),"\n",(0,r.jsxs)(n.li,{children:["having many types description including ",(0,r.jsx)(n.code,{children:"List"}),",",(0,r.jsx)(n.code,{children:"Mapping"})," and ",(0,r.jsx)(n.code,{children:"Struct"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["being directly usable in ",(0,r.jsx)(n.code,{children:"numpy"}),", ",(0,r.jsx)(n.code,{children:"pandas"}),", and ",(0,r.jsx)(n.code,{children:"pytorch"})," with zero-copy transmutation."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsx)(n.p,{children:"Dealing with efficient Interface is not the only challenge of bridging multiple languages. We also have to deal with cross-language debugging."}),"\n",(0,r.jsx)(n.h3,{id:"unwrap",children:(0,r.jsx)(n.code,{children:".unwrap()"})}),"\n",(0,r.jsxs)(n.p,{children:["Our current implementation uses ",(0,r.jsx)(n.code,{children:".unwrap()"}),". However, this will panic the whole Python process if there is an error."]}),"\n",(0,r.jsx)(n.h4,{id:"-example-error",children:"> Example error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"thread '' panicked at 'called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }', src/lib.rs:45:62\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\nTraceback (most recent call last):\n File \"/home/peter/Documents/work/blogpost_ffi/test_script.py\", line 79, in \n array = blogpost_ffi.create_list_arrow(1)\npyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }\n"})}),"\n",(0,r.jsx)(n.h3,{id:"eyre",children:(0,r.jsx)(n.a,{href:"https://github.com/eyre-rs/eyre",children:"eyre"})}),"\n",(0,r.jsxs)(n.p,{children:["Eyre is an easy idiomatic error handling library for Rust applications. We can use eyre by wrapping our ",(0,r.jsx)(n.code,{children:"pyo3"})," project with the ",(0,r.jsx)(n.code,{children:"pyo3/eyre"})," feature flag, to replace all our ",(0,r.jsx)(n.code,{children:".unwrap()"})," with a ",(0,r.jsx)(n.code,{children:'.context("our context")?'}),". This will transform unrecoverable errors into recoverable Python errors while giving details about our errors."]}),"\n",(0,r.jsxs)(n.h4,{id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",children:["> Same error as above but with ",(0,r.jsx)(n.code,{children:"eyre"})," which gives a better looking error message:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"Could not convert arrow data\n\nCaused by:\n TypeError: Expected instance of pyarrow.lib.Array, got builtins.int\n\nLocation:\n src/lib.rs:75:50\n"})}),"\n",(0,r.jsx)(n.p,{children:"Implementation details:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn create_list_arrow_eyre(py: Python, a: &PyAny) -> Result> {\n let arraydata =\n arrow::array::ArrayData::from_pyarrow(a).context("Could not convert arrow data")?;\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).context("Could not create pointer")?;\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .context("could not create arrow arraydata")?;\n\n output\n .to_pyarrow(py)\n .context("Could not convert to pyarrow")\n}\n\n'})}),"\n",(0,r.jsxs)(n.h3,{id:"python-traceback-with-eyre",children:["Python traceback with ",(0,r.jsx)(n.code,{children:"eyre"})]}),"\n",(0,r.jsx)(n.p,{children:"I will mention that you might lose the Python traceback error when calling Python code from a Rust code."}),"\n",(0,r.jsx)(n.p,{children:"I recommend using the following custom traceback method to have a descriptive error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn call_func_eyre(py: Python, func: Py) -> Result<()> { \n let _call_python = func.call0(py).context("function called failed")?;\n Ok(())\n}\n\nfn traceback(err: pyo3::PyErr) -> eyre::Report {\n let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok()));\n if let Some(traceback) = traceback {\n eyre::eyre!("{traceback}\\n{err}")\n } else {\n eyre::eyre!("{err}")\n }\n}\n\n#[pyfunction]\nfn call_func_eyre_traceback(py: Python, func: Py) -> Result<()> {\n let _call_python = func\n .call0(py)\n .map_err(traceback) // this will gives python traceback.\n .context("function called failed")?;\n Ok(())\n}\n'})}),"\n",(0,r.jsx)(n.h4,{id:"-example-error-with-no-custom-traceback",children:"> Example error with no custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"---Eyre no traceback---\neyre no traceback says: function called failed\n\nCaused by:\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:89:39\n------\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-better-errors-with-custom-traceback",children:"> Better errors with custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'---Eyre traceback---\neyre traceback says: function called failed\n\nCaused by:\n Traceback (most recent call last):\n File "/home/peter/Documents/work/blogpost_ffi/test_script.py", line 96, in abc\n assert False, "I have no idea what is wrong"\n\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:96:9\n------\n'})}),"\n",(0,r.jsx)(n.p,{children:"With the traceback, we can quickly identify the root error."}),"\n",(0,r.jsx)(n.h2,{id:"memory-management",children:"Memory management"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to create arrays within a loop:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"/// Unbounded memory growth\n#[pyfunction]\nfn unbounded_memory_growth(py: Python) -> Result<()> {\n for _ in 0..10 {\n let a: Vec = vec![0; 40_000_000];\n let _ = PyBytes::new(py, &a);`\n \n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-this-function-will-consume-440mb-of-memory--1",children:["> Calling this function will consume 440MB of memory. ","\ud83d\udc4e"]}),"\n",(0,r.jsxs)(n.p,{children:["What happened is that ",(0,r.jsx)(n.code,{children:"pyo3"})," memory model keeps all Python variables in memory until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["Therefore, if we create variables in a ",(0,r.jsx)(n.code,{children:"pyfunction"})," loop, all temporary variables are going to be kept until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["This is due to ",(0,r.jsx)(n.code,{children:"pyfunction"})," locking the GIL by default."]}),"\n",(0,r.jsx)(n.p,{children:"By understanding the GIL-based memory model, we can use a scoped GIL to have the expected behaviour:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn bounded_memory_growth(py: Python) -> Result<()> {\n py.allow_threads(|| {\n for _ in 0..10 {\n Python::with_gil(|py| {\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n \n std::thread::sleep(Duration::from_secs(1));\n });\n }\n });\n\n // or\n \n for _ in 0..10 {\n let pool = unsafe { py.new_pool() };\n let py = pool.python();\n\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n\n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",children:"> Calling this function will consume 80MB of memory. :thumbsup:"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://pyo3.rs/main/memory.html#gil-bound-memory",children:"More info can be found here"})}),"\n"]}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3/issues/3382",children:"Possible fix in Pyo3 0.21!"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"race-condition",children:"Race condition"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to process data in different threads:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// Function GIL Lock\n#[pyfunction]\nfn gil_lock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("This threaded print was printed after {:#?}", &start_time.elapsed()));\n });\n\n std::thread::sleep(Duration::from_secs(10));\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-this-threaded-print-was-printed-after-100s-cry",children:["> This threaded print was printed after 10.0s. ","\ud83d\ude22"]}),"\n",(0,r.jsxs)(n.p,{children:["When using Python with ",(0,r.jsx)(n.code,{children:"pyo3"}),", we have to make sure to know exactly when the GIL is locked or unlocked to avoid race conditions."]}),"\n",(0,r.jsxs)(n.p,{children:["In the example above, the issue is that by default ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to lock the GIL in the main function thread, therefore blocking the spawned thread that is waiting for the GIL."]}),"\n",(0,r.jsx)(n.p,{children:"If we use the GIL in the main function thread or release the GIL in the main function thread, there is no issue."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn gil_unlock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n std::thread::sleep(Duration::from_secs(10));\n });\n\n Python::with_gil(|py| println!("1. This was printed after {:#?}", &start_time.elapsed()));\n\n // or\n\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("2. This was printed after {:#?}", &start_time.elapsed()));\n });\n Python::with_gil(|py| {\n py.allow_threads(|| {\n std::thread::sleep(Duration::from_secs(10));\n })\n });\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",children:['> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. ',"\ud83d\ude04"]}),"\n",(0,r.jsx)(n.h2,{id:"tracing",children:"Tracing"}),"\n",(0,r.jsx)(n.p,{children:"As we can see, being able to measure the time spent when interfacing can be very valuable to identify bottlenecks."}),"\n",(0,r.jsx)(n.p,{children:"But measuring the time spent manually as we did before can be tedious."}),"\n",(0,r.jsxs)(n.p,{children:["What we can do is use a tracing library to do it for us. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can help us build a distributed observable system capable of bridging multiple languages. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can be used for tracing, metrics and logs."]}),"\n",(0,r.jsx)(n.p,{children:"For example, if we add:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn global_tracing(py: Python, func: Py) {\n // global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());\n global::set_text_map_propagator(TraceContextPropagator::new());\n\n // Connect to Jaeger Opentelemetry endpoint\n // Start a new endpoint with:\n // docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest\n let _tracer = opentelemetry_jaeger::new_agent_pipeline()\n .with_endpoint("172.17.0.1:6831")\n .with_service_name("rust_ffi")\n .install_simple()\n .unwrap();\n\n let tracer = global::tracer("test");\n\n // Parent Trace, first trace\n let _ = tracer.in_span("parent_python_work", |cx| -> Result<()> { \n std::thread::sleep(Duration::from_secs(1));\n \n let mut map = HashMap::new();\n global::get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut map));\n\n let output = func\n .call1(py, (map,))\n .map_err(traceback)\n .context("function called failed")?;\n let out_map: HashMap = output.extract(py).unwrap();\n let out_context = global::get_text_map_propagator(|prop| prop.extract(&out_map));\n\n std::thread::sleep(Duration::from_secs(1));\n\n let _span = tracer.start_with_context("after_python_work", &out_context); // third trace\n\n Ok(())\n });\n}\n'})}),"\n",(0,r.jsx)(n.p,{children:"And the following, in the Python code:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'def abc(cx):\n propagator = TraceContextTextMapPropagator()\n context = propagator.extract(carrier=cx)\n\n with tracing.tracer.start_as_current_span(\n name="Python_span", context=context\n ) as child_span:\n child_span.add_event("in Python!")\n output = {}\n tracing.propagator.inject(output)\n time.sleep(2)\n return output\n'})}),"\n",(0,r.jsx)(n.p,{children:"We will get the following traces:"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:t(69687).A+"",width:"3944",height:"1551"})}),"\n",(0,r.jsx)(n.p,{children:"Using this we can measure the time spent when interfacing languages, identify lock issues, and with the combination of logs and metrics, reduce the complexity of multi-language libraries."}),"\n",(0,r.jsx)(n.h1,{id:"dora-rs",children:(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})}),"\n",(0,r.jsx)(n.p,{children:"Hopefully, this small blog post should help you identify FFI issues."}),"\n",(0,r.jsxs)(n.p,{children:["All optimization above have already been implemented within ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," that lets you build fast and simple dataflows using Rust, Python, C and C++."]}),"\n",(0,r.jsxs)(n.p,{children:["You're very welcome to check out ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," if bridging languages in a dataflow is your usecase."]}),"\n",(0,r.jsxs)(n.p,{children:["We just recently opened a Discord and you can reach out there for literally any question, even just for a quick chat: ",(0,r.jsx)(n.a,{href:"https://discord.gg/DXJ6edAtym",children:"https://discord.gg/DXJ6edAtym"})]}),"\n",(0,r.jsxs)(n.p,{children:["I'm also going to present this FFI work at ",(0,r.jsx)(n.a,{href:"https://workshop2023.gosim.org/schedule#auto",children:"GOSIM Workshop in Shanghai on the 23rd of Sept 2023"}),"!"]}),"\n",(0,r.jsxs)(n.p,{children:["For more info on ",(0,r.jsx)(n.code,{children:"dora-rs"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Github: ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"https://github.com/dora-rs/dora"})]}),"\n",(0,r.jsxs)(n.li,{children:["Website: ",(0,r.jsx)(n.a,{href:"https://www.dora-rs.ai/",children:"https://www.dora-rs.ai/"})]}),"\n",(0,r.jsxs)(n.li,{children:["Discord: ",(0,r.jsx)(n.a,{href:"https://discord.gg/XqhQaN8P",children:"https://discord.gg/XqhQaN8P"})]}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},69687:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/blogpost_ffi-a663a0fdaf6f3a9acc323b2c364d01aa.png"},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>o});var r=t(96540);const a={},s=r.createContext(a);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file +"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[5159],{81819:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>o,toc:()=>c});var r=t(74848),a=t(28453);const s={authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},i=void 0,o={permalink:"/blog/rust-python",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/rust-python.md",source:"@site/blog/rust-python.md",title:"Rust-Python FFI",description:"Rust-Python FFI.",date:"2025-01-13T10:01:54.000Z",tags:[],readingTime:10.8,hasTruncateMarker:!1,authors:[{name:"Haixuan Xavier Tao",title:"Maintainer of dora-rs",url:"https://github.com/haixuantao",imageURL:"https://github.com/haixuantao.png",key:"haixuan"}],frontMatter:{authors:"haixuan",title:"Rust-Python FFI",description:"Rust-Python FFI."},unlisted:!1},l={authorsImageUrls:[void 0]},c=[{value:"Foreign Function Interface",id:"foreign-function-interface",level:2},{value:"Interfacing Arrays",id:"interfacing-arrays",level:2},{value:"Implementation 1: Default",id:"implementation-1-default",level:3},{value:"> Calling create_list for a very large list like: value = [1] * 100_000_000 is going to return in 2.27s \ud83d\ude9c",id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",level:4},{value:"Implementation 2: PyBytes",id:"implementation-2-pybytes",level:3},{value:"> For the same list input, create_list_bytes returns in 78 milliseconds. That's 30x better \ud83d\udc0e",id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",level:4},{value:"Implementation 3: Apache Arrow",id:"implementation-3-apache-arrow",level:3},{value:"> Same list returns in 33 milliseconds . That's 2x better than PyBytes \ud83d\udc0e\ud83d\udc0e",id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",level:4},{value:"Debugging",id:"debugging",level:2},{value:".unwrap()",id:"unwrap",level:3},{value:"> Example error:",id:"-example-error",level:4},{value:"eyre",id:"eyre",level:3},{value:"> Same error as above but with eyre which gives a better looking error message:",id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",level:4},{value:"Python traceback with eyre",id:"python-traceback-with-eyre",level:3},{value:"> Example error with no custom traceback:",id:"-example-error-with-no-custom-traceback",level:4},{value:"> Better errors with custom traceback:",id:"-better-errors-with-custom-traceback",level:4},{value:"Memory management",id:"memory-management",level:2},{value:"> Calling this function will consume 440MB of memory. \ud83d\udc4e",id:"-calling-this-function-will-consume-440mb-of-memory--1",level:4},{value:"> Calling this function will consume 80MB of memory. :thumbsup:",id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",level:4},{value:"Race condition",id:"race-condition",level:2},{value:"> This threaded print was printed after 10.0s. \ud83d\ude22",id:"-this-threaded-print-was-printed-after-100s-cry",level:4},{value:"> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. \ud83d\ude04",id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",level:4},{value:"Tracing",id:"tracing",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:"Writing a rust library that is usable in multiple languages is not easy..."}),"\n",(0,r.jsxs)(n.p,{children:["This blogpost recollects things I have encountered while building ",(0,r.jsx)(n.a,{href:"https://github.com/webonnx/wonnx",children:"wonnx"})," and ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"}),". I am going to use Rust-Python FFI through ",(0,r.jsx)(n.code,{children:"pyo3"})," as an example. You can then extrapolate those issues to other languages FFI."]}),"\n",(0,r.jsx)(n.h2,{id:"foreign-function-interface",children:"Foreign Function Interface"}),"\n",(0,r.jsx)(n.p,{children:"A foreign function interface (FFI) is an interface used to share data from different languages."}),"\n",(0,r.jsxs)(n.p,{children:["By default, python might not know what a Rust ",(0,r.jsx)(n.code,{children:"u16"})," is, so an interface is needed to make the two languages communicate."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://hackmd.io/_uploads/S1qiK8hRh.png",alt:""})}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Image from ",(0,r.jsx)(n.a,{href:"https://hacks.mozilla.org/2019/08/webassembly-interface-types/",children:"WebAssembly Interface Types: Interoperate with All the Things!"})]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"Building interfaces is not easy. Most of the time, we have to use the C-ABI to build our FFI as it is the common denominator between languages."}),"\n",(0,r.jsx)(n.p,{children:"Thankfully, there are FFI libraries that create interfaces for us and we can just focus on the important stuff such as the logic, algorithm, and so on."}),"\n",(0,r.jsx)(n.p,{children:"However, those FFI libraries might have limitations. This is what we're going to discuss."}),"\n",(0,r.jsxs)(n.p,{children:["One example of such FFI library is ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})}),". ",(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3",children:(0,r.jsx)(n.code,{children:"pyo3"})})," is one of the most used Rust-Python binding and creates FFIs for you. All we have to do is wrap our function with a ",(0,r.jsx)(n.code,{children:"#[pyfunction]"})," and that will make it usable in Python."]}),"\n",(0,r.jsx)(n.h2,{id:"interfacing-arrays",children:"Interfacing Arrays"}),"\n",(0,r.jsxs)(n.p,{children:["In this blog post, I'm going to build a toy Rust-Python project with ",(0,r.jsx)(n.code,{children:"pyo3"})," to illustrate the issues I have faced."]}),"\n",(0,r.jsxs)(n.p,{children:["You can try this blogpost at home by forking the ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi",children:"blogpost repository"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"If you want to start from scratch, you can create a new project with:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"mkdir blogpost_ffi\nmaturin init # pyo3\n"})}),"\n",(0,r.jsx)(n.p,{children:"The default project will looks like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"use pyo3::prelude::*;\n\n/// Formats the sum of two numbers as string.\n#[pyfunction]\nfn sum_as_string(a: usize, b: usize) -> PyResult {\n Ok((a + b).to_string())\n}\n\n/// A Python module implemented in Rust. The name of this function must match\n/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to\n/// import the module.\n#[pymodule]\nfn string_sum(_py: Python<'_>, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"We can call the function as follows:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'maturin develop\npython -c "import blogpost_ffi; print(blogpost_ffi.sum_as_string(1,1))"\n# Return: "2" \n'})}),"\n",(0,r.jsxs)(n.p,{children:["In the above example, ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to create FFIs to make Python integer interpretable as a Rust ",(0,r.jsx)(n.code,{children:"usize"})," without additional work."]}),"\n",(0,r.jsx)(n.p,{children:"However, automatically interpreted types might not be the most optimized implementation."}),"\n",(0,r.jsx)(n.h3,{id:"implementation-1-default",children:"Implementation 1: Default"}),"\n",(0,r.jsx)(n.p,{children:"Let's imagine that, we want to play with arrays, we want to receive an array input and return an array output between Rust and Python.\nA default inplementation, would look like this:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list(a: Vec<&PyAny>) -> PyResult> {\n Ok(a)\n}\n\n#[pymodule]\nfn blogpost_ffi(_py: Python, m: &PyModule) -> PyResult<()> {\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\n m.add_function(wrap_pyfunction!(create_list, m)?)?;\n Ok(())\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-create_list-for-a-very-large-list-like-value--1--100_000_000--is-going-to-return-in-227s-tractor",children:["> Calling ",(0,r.jsx)(n.code,{children:"create_list"})," for a very large list like: ",(0,r.jsx)(n.code,{children:"value = [1] * 100_000_000"})," is going to return in ",(0,r.jsx)(n.strong,{children:"2.27s"})," ","\ud83d\ude9c"]}),"\n",(0,r.jsx)(n.p,{children:"That's quite slow... The reason being is that this list is going to be interpret one element at a time in a loop. We can do better by trying to use all elements at the same time."}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Check ",(0,r.jsx)(n.a,{href:"https://github.com/haixuanTao/blogpost_ffi/blob/main/test_script.py",children:"test_script.py"})," for details on how the function is called."]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"implementation-2-pybytes",children:"Implementation 2: PyBytes"}),"\n",(0,r.jsxs)(n.p,{children:["Let's imagine that our array is a C-contiguous array that can be represented as a ",(0,r.jsx)(n.a,{href:"https://docs.python.org/3/library/stdtypes.html?highlight=bytes#bytes",children:(0,r.jsx)(n.code,{children:"PyBytes"})}),". The code can be optimized by casting the inputs and output as a ",(0,r.jsx)(n.code,{children:"PyBytes"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_bytes<'a>(py: Python<'a>, a: &'a PyBytes) -> PyResult<&'a PyBytes> {\n let s = a.as_bytes();\n\n let output = PyBytes::new_with(py, s.len(), |bytes| {\n bytes.copy_from_slice(s);\n Ok(())\n })?;\n Ok(output)\n}\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-for-the-same-list-input-create_list_bytes-returns-in-78-milliseconds-thats-30x-better-racehorse",children:["> For the same list input, ",(0,r.jsx)(n.code,{children:"create_list_bytes"})," returns in ",(0,r.jsx)(n.strong,{children:"78 milliseconds"}),". That's ",(0,r.jsx)(n.strong,{children:"30x"})," better ","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"The speedup comes from the possibility to copy the memory range instead of iterating each element and to read without copying."}),"\n",(0,r.jsx)(n.p,{children:"Now the issue is that:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," is only available in Python meaning that if we plan to have other languages, we will have to replicate this for each language."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," might also probably need to be reconverted into other useful types."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"PyBytes"})," needs a copy to be created."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["We can try to solve this with ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"}),"."]}),"\n",(0,r.jsxs)(n.h3,{id:"implementation-3-apache-arrow",children:["Implementation 3: ",(0,r.jsx)(n.a,{href:"https://arrow.apache.org/",children:"Apache Arrow"})]}),"\n",(0,r.jsx)(n.p,{children:"Apache Arrow is a universal memory format available in many languages."}),"\n",(0,r.jsxs)(n.p,{children:["The same function in ",(0,r.jsx)(n.code,{children:"arrow"})," would look like this:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn create_list_arrow(py: Python, a: &PyAny) -> PyResult> {\n let arraydata = arrow::array::ArrayData::from_pyarrow(a).unwrap();\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).unwrap();\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .unwrap();\n\n output.to_pyarrow(py)\n}\n\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-same-list-returns-in-33-milliseconds--thats-2x-better-than-pybytes-racehorseracehorse",children:["> Same list returns in ",(0,r.jsx)(n.strong,{children:"33 milliseconds"})," . That's ",(0,r.jsx)(n.strong,{children:"2x"})," better than ",(0,r.jsx)(n.code,{children:"PyBytes"})," ","\ud83d\udc0e","\ud83d\udc0e"]}),"\n",(0,r.jsx)(n.p,{children:"This is due to having zero copy when sending back the result. The zero-copying is safe because we are reference-counting the array. The array will be deallocating once all reference has been removed."}),"\n",(0,r.jsxs)(n.p,{children:["The benefits of ",(0,r.jsx)(n.code,{children:"arrow"})," is:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"to make zero-copy achievable, scaling better with bigger data."}),"\n",(0,r.jsx)(n.li,{children:"being reusable in other languages. We only have to replace the last line of the function with the export to the other languages."}),"\n",(0,r.jsxs)(n.li,{children:["having many types description including ",(0,r.jsx)(n.code,{children:"List"}),",",(0,r.jsx)(n.code,{children:"Mapping"})," and ",(0,r.jsx)(n.code,{children:"Struct"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:["being directly usable in ",(0,r.jsx)(n.code,{children:"numpy"}),", ",(0,r.jsx)(n.code,{children:"pandas"}),", and ",(0,r.jsx)(n.code,{children:"pytorch"})," with zero-copy transmutation."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsx)(n.p,{children:"Dealing with efficient Interface is not the only challenge of bridging multiple languages. We also have to deal with cross-language debugging."}),"\n",(0,r.jsx)(n.h3,{id:"unwrap",children:(0,r.jsx)(n.code,{children:".unwrap()"})}),"\n",(0,r.jsxs)(n.p,{children:["Our current implementation uses ",(0,r.jsx)(n.code,{children:".unwrap()"}),". However, this will panic the whole Python process if there is an error."]}),"\n",(0,r.jsx)(n.h4,{id:"-example-error",children:"> Example error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"thread '' panicked at 'called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }', src/lib.rs:45:62\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\nTraceback (most recent call last):\n File \"/home/peter/Documents/work/blogpost_ffi/test_script.py\", line 79, in \n array = blogpost_ffi.create_list_arrow(1)\npyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError('Expected instance of pyarrow.lib.Array, got builtins.int'), traceback: None }\n"})}),"\n",(0,r.jsx)(n.h3,{id:"eyre",children:(0,r.jsx)(n.a,{href:"https://github.com/eyre-rs/eyre",children:"eyre"})}),"\n",(0,r.jsxs)(n.p,{children:["Eyre is an easy idiomatic error handling library for Rust applications. We can use eyre by wrapping our ",(0,r.jsx)(n.code,{children:"pyo3"})," project with the ",(0,r.jsx)(n.code,{children:"pyo3/eyre"})," feature flag, to replace all our ",(0,r.jsx)(n.code,{children:".unwrap()"})," with a ",(0,r.jsx)(n.code,{children:'.context("our context")?'}),". This will transform unrecoverable errors into recoverable Python errors while giving details about our errors."]}),"\n",(0,r.jsxs)(n.h4,{id:"-same-error-as-above-but-with-eyre-which-gives-a-better-looking-error-message",children:["> Same error as above but with ",(0,r.jsx)(n.code,{children:"eyre"})," which gives a better looking error message:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"Could not convert arrow data\n\nCaused by:\n TypeError: Expected instance of pyarrow.lib.Array, got builtins.int\n\nLocation:\n src/lib.rs:75:50\n"})}),"\n",(0,r.jsx)(n.p,{children:"Implementation details:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn create_list_arrow_eyre(py: Python, a: &PyAny) -> Result> {\n let arraydata =\n arrow::array::ArrayData::from_pyarrow(a).context("Could not convert arrow data")?;\n\n let buffer = arraydata.buffers()[0].as_slice();\n let len = buffer.len();\n\n // Zero Copy Buffer reference counted\n let arc_s = Arc::new(buffer.to_vec());\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).context("Could not create pointer")?;\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\n let output = arrow::array::ArrayData::try_new(\n arrow::datatypes::DataType::UInt8,\n len,\n None,\n 0,\n vec![raw_buffer],\n vec![],\n )\n .context("could not create arrow arraydata")?;\n\n output\n .to_pyarrow(py)\n .context("Could not convert to pyarrow")\n}\n\n'})}),"\n",(0,r.jsxs)(n.h3,{id:"python-traceback-with-eyre",children:["Python traceback with ",(0,r.jsx)(n.code,{children:"eyre"})]}),"\n",(0,r.jsx)(n.p,{children:"I will mention that you might lose the Python traceback error when calling Python code from a Rust code."}),"\n",(0,r.jsx)(n.p,{children:"I recommend using the following custom traceback method to have a descriptive error:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'#[pyfunction]\nfn call_func_eyre(py: Python, func: Py) -> Result<()> { \n let _call_python = func.call0(py).context("function called failed")?;\n Ok(())\n}\n\nfn traceback(err: pyo3::PyErr) -> eyre::Report {\n let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok()));\n if let Some(traceback) = traceback {\n eyre::eyre!("{traceback}\\n{err}")\n } else {\n eyre::eyre!("{err}")\n }\n}\n\n#[pyfunction]\nfn call_func_eyre_traceback(py: Python, func: Py) -> Result<()> {\n let _call_python = func\n .call0(py)\n .map_err(traceback) // this will gives python traceback.\n .context("function called failed")?;\n Ok(())\n}\n'})}),"\n",(0,r.jsx)(n.h4,{id:"-example-error-with-no-custom-traceback",children:"> Example error with no custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"---Eyre no traceback---\neyre no traceback says: function called failed\n\nCaused by:\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:89:39\n------\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-better-errors-with-custom-traceback",children:"> Better errors with custom traceback:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'---Eyre traceback---\neyre traceback says: function called failed\n\nCaused by:\n Traceback (most recent call last):\n File "/home/peter/Documents/work/blogpost_ffi/test_script.py", line 96, in abc\n assert False, "I have no idea what is wrong"\n\n AssertionError: I have no idea what is wrong\n\nLocation:\n src/lib.rs:96:9\n------\n'})}),"\n",(0,r.jsx)(n.p,{children:"With the traceback, we can quickly identify the root error."}),"\n",(0,r.jsx)(n.h2,{id:"memory-management",children:"Memory management"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to create arrays within a loop:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"/// Unbounded memory growth\n#[pyfunction]\nfn unbounded_memory_growth(py: Python) -> Result<()> {\n for _ in 0..10 {\n let a: Vec = vec![0; 40_000_000];\n let _ = PyBytes::new(py, &a);`\n \n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n"})}),"\n",(0,r.jsxs)(n.h4,{id:"-calling-this-function-will-consume-440mb-of-memory--1",children:["> Calling this function will consume 440MB of memory. ","\ud83d\udc4e"]}),"\n",(0,r.jsxs)(n.p,{children:["What happened is that ",(0,r.jsx)(n.code,{children:"pyo3"})," memory model keeps all Python variables in memory until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["Therefore, if we create variables in a ",(0,r.jsx)(n.code,{children:"pyfunction"})," loop, all temporary variables are going to be kept until the GIL is released."]}),"\n",(0,r.jsxs)(n.p,{children:["This is due to ",(0,r.jsx)(n.code,{children:"pyfunction"})," locking the GIL by default."]}),"\n",(0,r.jsx)(n.p,{children:"By understanding the GIL-based memory model, we can use a scoped GIL to have the expected behaviour:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:"#[pyfunction]\nfn bounded_memory_growth(py: Python) -> Result<()> {\n py.allow_threads(|| {\n for _ in 0..10 {\n Python::with_gil(|py| {\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n \n std::thread::sleep(Duration::from_secs(1));\n });\n }\n });\n\n // or\n \n for _ in 0..10 {\n let pool = unsafe { py.new_pool() };\n let py = pool.python();\n\n let a: Vec = vec![0; 40_000_000];\n let _bytes = PyBytes::new(py, &a);\n\n std::thread::sleep(Duration::from_secs(1));\n }\n\n Ok(())\n}\n"})}),"\n",(0,r.jsx)(n.h4,{id:"-calling-this-function-will-consume-80mb-of-memory-thumbsup",children:"> Calling this function will consume 80MB of memory. :thumbsup:"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://pyo3.rs/main/memory.html#gil-bound-memory",children:"More info can be found here"})}),"\n"]}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/PyO3/pyo3/issues/3382",children:"Possible fix in Pyo3 0.21!"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"race-condition",children:"Race condition"}),"\n",(0,r.jsx)(n.p,{children:"Let's take another example, and imagine that we need to process data in different threads:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// Function GIL Lock\n#[pyfunction]\nfn gil_lock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("This threaded print was printed after {:#?}", &start_time.elapsed()));\n });\n\n std::thread::sleep(Duration::from_secs(10));\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-this-threaded-print-was-printed-after-100s-cry",children:["> This threaded print was printed after 10.0s. ","\ud83d\ude22"]}),"\n",(0,r.jsxs)(n.p,{children:["When using Python with ",(0,r.jsx)(n.code,{children:"pyo3"}),", we have to make sure to know exactly when the GIL is locked or unlocked to avoid race conditions."]}),"\n",(0,r.jsxs)(n.p,{children:["In the example above, the issue is that by default ",(0,r.jsx)(n.code,{children:"pyo3"})," is going to lock the GIL in the main function thread, therefore blocking the spawned thread that is waiting for the GIL."]}),"\n",(0,r.jsx)(n.p,{children:"If we use the GIL in the main function thread or release the GIL in the main function thread, there is no issue."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn gil_unlock() {\n let start_time = Instant::now();\n std::thread::spawn(move || {\n std::thread::sleep(Duration::from_secs(10));\n });\n\n Python::with_gil(|py| println!("1. This was printed after {:#?}", &start_time.elapsed()));\n\n // or\n\n let start_time = Instant::now();\n std::thread::spawn(move || {\n Python::with_gil(|py| println!("2. This was printed after {:#?}", &start_time.elapsed()));\n });\n Python::with_gil(|py| {\n py.allow_threads(|| {\n std::thread::sleep(Duration::from_secs(10));\n })\n });\n}\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"-1-was-printed-after-32\xb5s-and-2-was-printed-after-80\xb5s-so-there-was-no-race-condition-smile",children:['> "1" was printed after 32\xb5s and "2" was printed after 80\xb5s, so there was no race condition. ',"\ud83d\ude04"]}),"\n",(0,r.jsx)(n.h2,{id:"tracing",children:"Tracing"}),"\n",(0,r.jsx)(n.p,{children:"As we can see, being able to measure the time spent when interfacing can be very valuable to identify bottlenecks."}),"\n",(0,r.jsx)(n.p,{children:"But measuring the time spent manually as we did before can be tedious."}),"\n",(0,r.jsxs)(n.p,{children:["What we can do is use a tracing library to do it for us. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can help us build a distributed observable system capable of bridging multiple languages. ",(0,r.jsx)(n.a,{href:"https://opentelemetry.io/",children:"Opentelemetry"})," can be used for tracing, metrics and logs."]}),"\n",(0,r.jsx)(n.p,{children:"For example, if we add:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-rust",children:'/// No gil lock\n#[pyfunction]\nfn global_tracing(py: Python, func: Py) {\n // global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());\n global::set_text_map_propagator(TraceContextPropagator::new());\n\n // Connect to Jaeger Opentelemetry endpoint\n // Start a new endpoint with:\n // docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest\n let _tracer = opentelemetry_jaeger::new_agent_pipeline()\n .with_endpoint("172.17.0.1:6831")\n .with_service_name("rust_ffi")\n .install_simple()\n .unwrap();\n\n let tracer = global::tracer("test");\n\n // Parent Trace, first trace\n let _ = tracer.in_span("parent_python_work", |cx| -> Result<()> { \n std::thread::sleep(Duration::from_secs(1));\n \n let mut map = HashMap::new();\n global::get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut map));\n\n let output = func\n .call1(py, (map,))\n .map_err(traceback)\n .context("function called failed")?;\n let out_map: HashMap = output.extract(py).unwrap();\n let out_context = global::get_text_map_propagator(|prop| prop.extract(&out_map));\n\n std::thread::sleep(Duration::from_secs(1));\n\n let _span = tracer.start_with_context("after_python_work", &out_context); // third trace\n\n Ok(())\n });\n}\n'})}),"\n",(0,r.jsx)(n.p,{children:"And the following, in the Python code:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'def abc(cx):\n propagator = TraceContextTextMapPropagator()\n context = propagator.extract(carrier=cx)\n\n with tracing.tracer.start_as_current_span(\n name="Python_span", context=context\n ) as child_span:\n child_span.add_event("in Python!")\n output = {}\n tracing.propagator.inject(output)\n time.sleep(2)\n return output\n'})}),"\n",(0,r.jsx)(n.p,{children:"We will get the following traces:"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:t(69687).A+"",width:"3944",height:"1551"})}),"\n",(0,r.jsx)(n.p,{children:"Using this we can measure the time spent when interfacing languages, identify lock issues, and with the combination of logs and metrics, reduce the complexity of multi-language libraries."}),"\n",(0,r.jsx)(n.h1,{id:"dora-rs",children:(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})}),"\n",(0,r.jsx)(n.p,{children:"Hopefully, this small blog post should help you identify FFI issues."}),"\n",(0,r.jsxs)(n.p,{children:["All optimization above have already been implemented within ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," that lets you build fast and simple dataflows using Rust, Python, C and C++."]}),"\n",(0,r.jsxs)(n.p,{children:["You're very welcome to check out ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"dora-rs"})," if bridging languages in a dataflow is your usecase."]}),"\n",(0,r.jsxs)(n.p,{children:["We just recently opened a Discord and you can reach out there for literally any question, even just for a quick chat: ",(0,r.jsx)(n.a,{href:"https://discord.gg/DXJ6edAtym",children:"https://discord.gg/DXJ6edAtym"})]}),"\n",(0,r.jsxs)(n.p,{children:["I'm also going to present this FFI work at ",(0,r.jsx)(n.a,{href:"https://workshop2023.gosim.org/schedule#auto",children:"GOSIM Workshop in Shanghai on the 23rd of Sept 2023"}),"!"]}),"\n",(0,r.jsxs)(n.p,{children:["For more info on ",(0,r.jsx)(n.code,{children:"dora-rs"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Github: ",(0,r.jsx)(n.a,{href:"https://github.com/dora-rs/dora",children:"https://github.com/dora-rs/dora"})]}),"\n",(0,r.jsxs)(n.li,{children:["Website: ",(0,r.jsx)(n.a,{href:"https://www.dora-rs.ai/",children:"https://www.dora-rs.ai/"})]}),"\n",(0,r.jsxs)(n.li,{children:["Discord: ",(0,r.jsx)(n.a,{href:"https://discord.gg/XqhQaN8P",children:"https://discord.gg/XqhQaN8P"})]}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},69687:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/blogpost_ffi-a663a0fdaf6f3a9acc323b2c364d01aa.png"},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>o});var r=t(96540);const a={},s=r.createContext(a);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/b2f554cd.0cfabe3d.js b/assets/js/b2f554cd.505c317f.js similarity index 99% rename from assets/js/b2f554cd.0cfabe3d.js rename to assets/js/b2f554cd.505c317f.js index a723698f..da54d3e4 100644 --- a/assets/js/b2f554cd.0cfabe3d.js +++ b/assets/js/b2f554cd.505c317f.js @@ -1 +1 @@ -"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[5894],{76042:n=>{n.exports=JSON.parse('{"blogPosts":[{"id":"/rust-python","metadata":{"permalink":"/blog/rust-python","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/rust-python.md","source":"@site/blog/rust-python.md","title":"Rust-Python FFI","description":"Rust-Python FFI.","date":"2025-01-11T14:26:10.000Z","tags":[],"readingTime":10.8,"hasTruncateMarker":false,"authors":[{"name":"Haixuan Xavier Tao","title":"Maintainer of dora-rs","url":"https://github.com/haixuantao","imageURL":"https://github.com/haixuantao.png","key":"haixuan"}],"frontMatter":{"authors":"haixuan","title":"Rust-Python FFI","description":"Rust-Python FFI."},"unlisted":false},"content":"Writing a rust library that is usable in multiple languages is not easy...\\n\\nThis blogpost recollects things I have encountered while building [wonnx](https://github.com/webonnx/wonnx) and [dora-rs](https://github.com/dora-rs/dora). I am going to use Rust-Python FFI through `pyo3` as an example. You can then extrapolate those issues to other languages FFI.\\n\\n## Foreign Function Interface\\n\\nA foreign function interface (FFI) is an interface used to share data from different languages. \\n\\nBy default, python might not know what a Rust `u16` is, so an interface is needed to make the two languages communicate.\\n\\n![](https://hackmd.io/_uploads/S1qiK8hRh.png)\\n> Image from [WebAssembly Interface Types: Interoperate with All the Things!](https://hacks.mozilla.org/2019/08/webassembly-interface-types/)\\n\\nBuilding interfaces is not easy. Most of the time, we have to use the C-ABI to build our FFI as it is the common denominator between languages.\\n\\nThankfully, there are FFI libraries that create interfaces for us and we can just focus on the important stuff such as the logic, algorithm, and so on.\\n\\nHowever, those FFI libraries might have limitations. This is what we\'re going to discuss.\\n\\nOne example of such FFI library is [`pyo3`](https://github.com/PyO3/pyo3). [`pyo3`](https://github.com/PyO3/pyo3) is one of the most used Rust-Python binding and creates FFIs for you. All we have to do is wrap our function with a `#[pyfunction]` and that will make it usable in Python.\\n\\n## Interfacing Arrays\\n\\nIn this blog post, I\'m going to build a toy Rust-Python project with `pyo3` to illustrate the issues I have faced.\\n\\nYou can try this blogpost at home by forking the [blogpost repository](https://github.com/haixuanTao/blogpost_ffi).\\n\\nIf you want to start from scratch, you can create a new project with:\\n\\n```bash\\nmkdir blogpost_ffi\\nmaturin init # pyo3\\n```\\n\\nThe default project will looks like this:\\n\\n```rust\\nuse pyo3::prelude::*;\\n\\n/// Formats the sum of two numbers as string.\\n#[pyfunction]\\nfn sum_as_string(a: usize, b: usize) -> PyResult {\\n Ok((a + b).to_string())\\n}\\n\\n/// A Python module implemented in Rust. The name of this function must match\\n/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to\\n/// import the module.\\n#[pymodule]\\nfn string_sum(_py: Python<\'_>, m: &PyModule) -> PyResult<()> {\\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\\n Ok(())\\n}\\n```\\nWe can call the function as follows:\\n```bash\\nmaturin develop\\npython -c \\"import blogpost_ffi; print(blogpost_ffi.sum_as_string(1,1))\\"\\n# Return: \\"2\\" \\n```\\n\\nIn the above example, `pyo3` is going to create FFIs to make Python integer interpretable as a Rust `usize` without additional work. \\n\\nHowever, automatically interpreted types might not be the most optimized implementation.\\n\\n\\n### Implementation 1: Default\\n\\nLet\'s imagine that, we want to play with arrays, we want to receive an array input and return an array output between Rust and Python.\\nA default inplementation, would look like this:\\n\\n\\n```rust \\n#[pyfunction]\\nfn create_list(a: Vec<&PyAny>) -> PyResult> {\\n Ok(a)\\n}\\n\\n#[pymodule]\\nfn blogpost_ffi(_py: Python, m: &PyModule) -> PyResult<()> {\\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\\n m.add_function(wrap_pyfunction!(create_list, m)?)?;\\n Ok(())\\n}\\n\\n```\\n\\n#### > Calling `create_list` for a very large list like: `value = [1] * 100_000_000` is going to return in **2.27s** :tractor: \\n\\nThat\'s quite slow... The reason being is that this list is going to be interpret one element at a time in a loop. We can do better by trying to use all elements at the same time.\\n\\n> Check [test_script.py](https://github.com/haixuanTao/blogpost_ffi/blob/main/test_script.py) for details on how the function is called.\\n\\n### Implementation 2: PyBytes\\n\\nLet\'s imagine that our array is a C-contiguous array that can be represented as a [`PyBytes`](https://docs.python.org/3/library/stdtypes.html?highlight=bytes#bytes). The code can be optimized by casting the inputs and output as a `PyBytes`:\\n```rust\\n#[pyfunction]\\nfn create_list_bytes<\'a>(py: Python<\'a>, a: &\'a PyBytes) -> PyResult<&\'a PyBytes> {\\n let s = a.as_bytes();\\n\\n let output = PyBytes::new_with(py, s.len(), |bytes| {\\n bytes.copy_from_slice(s);\\n Ok(())\\n })?;\\n Ok(output)\\n}\\n```\\n\\n#### > For the same list input, `create_list_bytes` returns in **78 milliseconds**. That\'s **30x** better :racehorse: \\n\\n\\nThe speedup comes from the possibility to copy the memory range instead of iterating each element and to read without copying.\\n\\nNow the issue is that:\\n- `PyBytes` is only available in Python meaning that if we plan to have other languages, we will have to replicate this for each language.\\n- `PyBytes` might also probably need to be reconverted into other useful types.\\n- `PyBytes` needs a copy to be created.\\n\\nWe can try to solve this with [Apache Arrow](https://arrow.apache.org/).\\n\\n### Implementation 3: [Apache Arrow](https://arrow.apache.org/)\\n\\nApache Arrow is a universal memory format available in many languages. \\n\\nThe same function in `arrow` would look like this:\\n```rust \\n#[pyfunction]\\nfn create_list_arrow(py: Python, a: &PyAny) -> PyResult> {\\n let arraydata = arrow::array::ArrayData::from_pyarrow(a).unwrap();\\n\\n let buffer = arraydata.buffers()[0].as_slice();\\n let len = buffer.len();\\n\\n // Zero Copy Buffer reference counted\\n let arc_s = Arc::new(buffer.to_vec());\\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).unwrap();\\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\\n let output = arrow::array::ArrayData::try_new(\\n arrow::datatypes::DataType::UInt8,\\n len,\\n None,\\n 0,\\n vec![raw_buffer],\\n vec![],\\n )\\n .unwrap();\\n\\n output.to_pyarrow(py)\\n}\\n\\n```\\n\\n\\n#### > Same list returns in **33 milliseconds** . That\'s **2x** better than `PyBytes` :racehorse::racehorse: \\n\\n\\nThis is due to having zero copy when sending back the result. The zero-copying is safe because we are reference-counting the array. The array will be deallocating once all reference has been removed. \\n\\nThe benefits of `arrow` is:\\n- to make zero-copy achievable, scaling better with bigger data.\\n- being reusable in other languages. We only have to replace the last line of the function with the export to the other languages. \\n- having many types description including `List`,`Mapping` and `Struct`.\\n- being directly usable in `numpy`, `pandas`, and `pytorch` with zero-copy transmutation.\\n\\n## Debugging\\n\\nDealing with efficient Interface is not the only challenge of bridging multiple languages. We also have to deal with cross-language debugging. \\n\\n### `.unwrap()`\\n\\nOur current implementation uses `.unwrap()`. However, this will panic the whole Python process if there is an error. \\n\\n#### > Example error:\\n```bash\\nthread \'\' panicked at \'called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError(\'Expected instance of pyarrow.lib.Array, got builtins.int\'), traceback: None }\', src/lib.rs:45:62\\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\\nTraceback (most recent call last):\\n File \\"/home/peter/Documents/work/blogpost_ffi/test_script.py\\", line 79, in \\n array = blogpost_ffi.create_list_arrow(1)\\npyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError(\'Expected instance of pyarrow.lib.Array, got builtins.int\'), traceback: None }\\n```\\n\\n### [eyre](https://github.com/eyre-rs/eyre)\\n\\nEyre is an easy idiomatic error handling library for Rust applications. We can use eyre by wrapping our `pyo3` project with the `pyo3/eyre` feature flag, to replace all our `.unwrap()` with a `.context(\\"our context\\")?`. This will transform unrecoverable errors into recoverable Python errors while giving details about our errors.\\n\\n#### > Same error as above but with `eyre` which gives a better looking error message:\\n```bash\\nCould not convert arrow data\\n\\nCaused by:\\n TypeError: Expected instance of pyarrow.lib.Array, got builtins.int\\n\\nLocation:\\n src/lib.rs:75:50\\n```\\n\\nImplementation details:\\n```rust\\n#[pyfunction]\\nfn create_list_arrow_eyre(py: Python, a: &PyAny) -> Result> {\\n let arraydata =\\n arrow::array::ArrayData::from_pyarrow(a).context(\\"Could not convert arrow data\\")?;\\n\\n let buffer = arraydata.buffers()[0].as_slice();\\n let len = buffer.len();\\n\\n // Zero Copy Buffer reference counted\\n let arc_s = Arc::new(buffer.to_vec());\\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).context(\\"Could not create pointer\\")?;\\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\\n let output = arrow::array::ArrayData::try_new(\\n arrow::datatypes::DataType::UInt8,\\n len,\\n None,\\n 0,\\n vec![raw_buffer],\\n vec![],\\n )\\n .context(\\"could not create arrow arraydata\\")?;\\n\\n output\\n .to_pyarrow(py)\\n .context(\\"Could not convert to pyarrow\\")\\n}\\n\\n```\\n\\n### Python traceback with `eyre`\\n\\nI will mention that you might lose the Python traceback error when calling Python code from a Rust code.\\n\\nI recommend using the following custom traceback method to have a descriptive error:\\n```rust\\n#[pyfunction]\\nfn call_func_eyre(py: Python, func: Py) -> Result<()> { \\n let _call_python = func.call0(py).context(\\"function called failed\\")?;\\n Ok(())\\n}\\n\\nfn traceback(err: pyo3::PyErr) -> eyre::Report {\\n let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok()));\\n if let Some(traceback) = traceback {\\n eyre::eyre!(\\"{traceback}\\\\n{err}\\")\\n } else {\\n eyre::eyre!(\\"{err}\\")\\n }\\n}\\n\\n#[pyfunction]\\nfn call_func_eyre_traceback(py: Python, func: Py) -> Result<()> {\\n let _call_python = func\\n .call0(py)\\n .map_err(traceback) // this will gives python traceback.\\n .context(\\"function called failed\\")?;\\n Ok(())\\n}\\n```\\n\\n#### > Example error with no custom traceback:\\n\\n```\\n---Eyre no traceback---\\neyre no traceback says: function called failed\\n\\nCaused by:\\n AssertionError: I have no idea what is wrong\\n\\nLocation:\\n src/lib.rs:89:39\\n------\\n```\\n\\n#### > Better errors with custom traceback:\\n\\n```\\n---Eyre traceback---\\neyre traceback says: function called failed\\n\\nCaused by:\\n Traceback (most recent call last):\\n File \\"/home/peter/Documents/work/blogpost_ffi/test_script.py\\", line 96, in abc\\n assert False, \\"I have no idea what is wrong\\"\\n\\n AssertionError: I have no idea what is wrong\\n\\nLocation:\\n src/lib.rs:96:9\\n------\\n```\\n\\nWith the traceback, we can quickly identify the root error. \\n\\n## Memory management\\n\\nLet\'s take another example, and imagine that we need to create arrays within a loop:\\n\\n```rust\\n/// Unbounded memory growth\\n#[pyfunction]\\nfn unbounded_memory_growth(py: Python) -> Result<()> {\\n for _ in 0..10 {\\n let a: Vec = vec![0; 40_000_000];\\n let _ = PyBytes::new(py, &a);`\\n \\n std::thread::sleep(Duration::from_secs(1));\\n }\\n\\n Ok(())\\n```\\n\\n#### > Calling this function will consume 440MB of memory. :-1: \\n\\nWhat happened is that `pyo3` memory model keeps all Python variables in memory until the GIL is released.\\n\\nTherefore, if we create variables in a `pyfunction` loop, all temporary variables are going to be kept until the GIL is released. \\n\\nThis is due to `pyfunction` locking the GIL by default.\\n\\nBy understanding the GIL-based memory model, we can use a scoped GIL to have the expected behaviour:\\n\\n```rust\\n#[pyfunction]\\nfn bounded_memory_growth(py: Python) -> Result<()> {\\n py.allow_threads(|| {\\n for _ in 0..10 {\\n Python::with_gil(|py| {\\n let a: Vec = vec![0; 40_000_000];\\n let _bytes = PyBytes::new(py, &a);\\n \\n std::thread::sleep(Duration::from_secs(1));\\n });\\n }\\n });\\n\\n // or\\n \\n for _ in 0..10 {\\n let pool = unsafe { py.new_pool() };\\n let py = pool.python();\\n\\n let a: Vec = vec![0; 40_000_000];\\n let _bytes = PyBytes::new(py, &a);\\n\\n std::thread::sleep(Duration::from_secs(1));\\n }\\n\\n Ok(())\\n}\\n```\\n\\n#### > Calling this function will consume 80MB of memory. :thumbsup: \\n\\n> [More info can be found here](https://pyo3.rs/main/memory.html#gil-bound-memory)\\n\\n> [Possible fix in Pyo3 0.21!](https://github.com/PyO3/pyo3/issues/3382)\\n>\\n\\n## Race condition\\n\\nLet\'s take another example, and imagine that we need to process data in different threads:\\n\\n```rust\\n/// Function GIL Lock\\n#[pyfunction]\\nfn gil_lock() {\\n let start_time = Instant::now();\\n std::thread::spawn(move || {\\n Python::with_gil(|py| println!(\\"This threaded print was printed after {:#?}\\", &start_time.elapsed()));\\n });\\n\\n std::thread::sleep(Duration::from_secs(10));\\n}\\n```\\n\\n#### > This threaded print was printed after 10.0s. :cry: \\n\\nWhen using Python with `pyo3`, we have to make sure to know exactly when the GIL is locked or unlocked to avoid race conditions. \\n\\nIn the example above, the issue is that by default `pyo3` is going to lock the GIL in the main function thread, therefore blocking the spawned thread that is waiting for the GIL.\\n\\nIf we use the GIL in the main function thread or release the GIL in the main function thread, there is no issue.\\n\\n```rust\\n/// No gil lock\\n#[pyfunction]\\nfn gil_unlock() {\\n let start_time = Instant::now();\\n std::thread::spawn(move || {\\n std::thread::sleep(Duration::from_secs(10));\\n });\\n\\n Python::with_gil(|py| println!(\\"1. This was printed after {:#?}\\", &start_time.elapsed()));\\n\\n // or\\n\\n let start_time = Instant::now();\\n std::thread::spawn(move || {\\n Python::with_gil(|py| println!(\\"2. This was printed after {:#?}\\", &start_time.elapsed()));\\n });\\n Python::with_gil(|py| {\\n py.allow_threads(|| {\\n std::thread::sleep(Duration::from_secs(10));\\n })\\n });\\n}\\n```\\n#### > \\"1\\" was printed after 32\xb5s and \\"2\\" was printed after 80\xb5s, so there was no race condition. :smile: \\n\\n## Tracing\\n\\nAs we can see, being able to measure the time spent when interfacing can be very valuable to identify bottlenecks. \\n\\nBut measuring the time spent manually as we did before can be tedious. \\n\\nWhat we can do is use a tracing library to do it for us. [Opentelemetry](https://opentelemetry.io/) can help us build a distributed observable system capable of bridging multiple languages. [Opentelemetry](https://opentelemetry.io/) can be used for tracing, metrics and logs.\\n\\nFor example, if we add:\\n```rust \\n/// No gil lock\\n#[pyfunction]\\nfn global_tracing(py: Python, func: Py) {\\n // global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());\\n global::set_text_map_propagator(TraceContextPropagator::new());\\n\\n // Connect to Jaeger Opentelemetry endpoint\\n // Start a new endpoint with:\\n // docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest\\n let _tracer = opentelemetry_jaeger::new_agent_pipeline()\\n .with_endpoint(\\"172.17.0.1:6831\\")\\n .with_service_name(\\"rust_ffi\\")\\n .install_simple()\\n .unwrap();\\n\\n let tracer = global::tracer(\\"test\\");\\n\\n // Parent Trace, first trace\\n let _ = tracer.in_span(\\"parent_python_work\\", |cx| -> Result<()> { \\n std::thread::sleep(Duration::from_secs(1));\\n \\n let mut map = HashMap::new();\\n global::get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut map));\\n\\n let output = func\\n .call1(py, (map,))\\n .map_err(traceback)\\n .context(\\"function called failed\\")?;\\n let out_map: HashMap = output.extract(py).unwrap();\\n let out_context = global::get_text_map_propagator(|prop| prop.extract(&out_map));\\n\\n std::thread::sleep(Duration::from_secs(1));\\n\\n let _span = tracer.start_with_context(\\"after_python_work\\", &out_context); // third trace\\n\\n Ok(())\\n });\\n}\\n```\\n\\n\\nAnd the following, in the Python code:\\n```python\\ndef abc(cx):\\n propagator = TraceContextTextMapPropagator()\\n context = propagator.extract(carrier=cx)\\n\\n with tracing.tracer.start_as_current_span(\\n name=\\"Python_span\\", context=context\\n ) as child_span:\\n child_span.add_event(\\"in Python!\\")\\n output = {}\\n tracing.propagator.inject(output)\\n time.sleep(2)\\n return output\\n```\\n\\nWe will get the following traces:\\n\\n![](/img/blogpost_ffi.png)\\n\\nUsing this we can measure the time spent when interfacing languages, identify lock issues, and with the combination of logs and metrics, reduce the complexity of multi-language libraries.\\n\\n# [dora-rs](https://github.com/dora-rs/dora)\\n\\nHopefully, this small blog post should help you identify FFI issues. \\n\\nAll optimization above have already been implemented within [dora-rs](https://github.com/dora-rs/dora) that lets you build fast and simple dataflows using Rust, Python, C and C++.\\n\\nYou\'re very welcome to check out [dora-rs](https://github.com/dora-rs/dora) if bridging languages in a dataflow is your usecase.\\n\\nWe just recently opened a Discord and you can reach out there for literally any question, even just for a quick chat: https://discord.gg/DXJ6edAtym\\n\\nI\'m also going to present this FFI work at [GOSIM Workshop in Shanghai on the 23rd of Sept 2023](https://workshop2023.gosim.org/schedule#auto)!\\n\\nFor more info on `dora-rs`:\\n- Github: https://github.com/dora-rs/dora\\n- Website: https://www.dora-rs.ai/\\n- Discord: https://discord.gg/XqhQaN8P"}]}')}}]); \ No newline at end of file +"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[5894],{76042:n=>{n.exports=JSON.parse('{"blogPosts":[{"id":"/rust-python","metadata":{"permalink":"/blog/rust-python","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/rust-python.md","source":"@site/blog/rust-python.md","title":"Rust-Python FFI","description":"Rust-Python FFI.","date":"2025-01-13T10:01:54.000Z","tags":[],"readingTime":10.8,"hasTruncateMarker":false,"authors":[{"name":"Haixuan Xavier Tao","title":"Maintainer of dora-rs","url":"https://github.com/haixuantao","imageURL":"https://github.com/haixuantao.png","key":"haixuan"}],"frontMatter":{"authors":"haixuan","title":"Rust-Python FFI","description":"Rust-Python FFI."},"unlisted":false},"content":"Writing a rust library that is usable in multiple languages is not easy...\\n\\nThis blogpost recollects things I have encountered while building [wonnx](https://github.com/webonnx/wonnx) and [dora-rs](https://github.com/dora-rs/dora). I am going to use Rust-Python FFI through `pyo3` as an example. You can then extrapolate those issues to other languages FFI.\\n\\n## Foreign Function Interface\\n\\nA foreign function interface (FFI) is an interface used to share data from different languages. \\n\\nBy default, python might not know what a Rust `u16` is, so an interface is needed to make the two languages communicate.\\n\\n![](https://hackmd.io/_uploads/S1qiK8hRh.png)\\n> Image from [WebAssembly Interface Types: Interoperate with All the Things!](https://hacks.mozilla.org/2019/08/webassembly-interface-types/)\\n\\nBuilding interfaces is not easy. Most of the time, we have to use the C-ABI to build our FFI as it is the common denominator between languages.\\n\\nThankfully, there are FFI libraries that create interfaces for us and we can just focus on the important stuff such as the logic, algorithm, and so on.\\n\\nHowever, those FFI libraries might have limitations. This is what we\'re going to discuss.\\n\\nOne example of such FFI library is [`pyo3`](https://github.com/PyO3/pyo3). [`pyo3`](https://github.com/PyO3/pyo3) is one of the most used Rust-Python binding and creates FFIs for you. All we have to do is wrap our function with a `#[pyfunction]` and that will make it usable in Python.\\n\\n## Interfacing Arrays\\n\\nIn this blog post, I\'m going to build a toy Rust-Python project with `pyo3` to illustrate the issues I have faced.\\n\\nYou can try this blogpost at home by forking the [blogpost repository](https://github.com/haixuanTao/blogpost_ffi).\\n\\nIf you want to start from scratch, you can create a new project with:\\n\\n```bash\\nmkdir blogpost_ffi\\nmaturin init # pyo3\\n```\\n\\nThe default project will looks like this:\\n\\n```rust\\nuse pyo3::prelude::*;\\n\\n/// Formats the sum of two numbers as string.\\n#[pyfunction]\\nfn sum_as_string(a: usize, b: usize) -> PyResult {\\n Ok((a + b).to_string())\\n}\\n\\n/// A Python module implemented in Rust. The name of this function must match\\n/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to\\n/// import the module.\\n#[pymodule]\\nfn string_sum(_py: Python<\'_>, m: &PyModule) -> PyResult<()> {\\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\\n Ok(())\\n}\\n```\\nWe can call the function as follows:\\n```bash\\nmaturin develop\\npython -c \\"import blogpost_ffi; print(blogpost_ffi.sum_as_string(1,1))\\"\\n# Return: \\"2\\" \\n```\\n\\nIn the above example, `pyo3` is going to create FFIs to make Python integer interpretable as a Rust `usize` without additional work. \\n\\nHowever, automatically interpreted types might not be the most optimized implementation.\\n\\n\\n### Implementation 1: Default\\n\\nLet\'s imagine that, we want to play with arrays, we want to receive an array input and return an array output between Rust and Python.\\nA default inplementation, would look like this:\\n\\n\\n```rust \\n#[pyfunction]\\nfn create_list(a: Vec<&PyAny>) -> PyResult> {\\n Ok(a)\\n}\\n\\n#[pymodule]\\nfn blogpost_ffi(_py: Python, m: &PyModule) -> PyResult<()> {\\n m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;\\n m.add_function(wrap_pyfunction!(create_list, m)?)?;\\n Ok(())\\n}\\n\\n```\\n\\n#### > Calling `create_list` for a very large list like: `value = [1] * 100_000_000` is going to return in **2.27s** :tractor: \\n\\nThat\'s quite slow... The reason being is that this list is going to be interpret one element at a time in a loop. We can do better by trying to use all elements at the same time.\\n\\n> Check [test_script.py](https://github.com/haixuanTao/blogpost_ffi/blob/main/test_script.py) for details on how the function is called.\\n\\n### Implementation 2: PyBytes\\n\\nLet\'s imagine that our array is a C-contiguous array that can be represented as a [`PyBytes`](https://docs.python.org/3/library/stdtypes.html?highlight=bytes#bytes). The code can be optimized by casting the inputs and output as a `PyBytes`:\\n```rust\\n#[pyfunction]\\nfn create_list_bytes<\'a>(py: Python<\'a>, a: &\'a PyBytes) -> PyResult<&\'a PyBytes> {\\n let s = a.as_bytes();\\n\\n let output = PyBytes::new_with(py, s.len(), |bytes| {\\n bytes.copy_from_slice(s);\\n Ok(())\\n })?;\\n Ok(output)\\n}\\n```\\n\\n#### > For the same list input, `create_list_bytes` returns in **78 milliseconds**. That\'s **30x** better :racehorse: \\n\\n\\nThe speedup comes from the possibility to copy the memory range instead of iterating each element and to read without copying.\\n\\nNow the issue is that:\\n- `PyBytes` is only available in Python meaning that if we plan to have other languages, we will have to replicate this for each language.\\n- `PyBytes` might also probably need to be reconverted into other useful types.\\n- `PyBytes` needs a copy to be created.\\n\\nWe can try to solve this with [Apache Arrow](https://arrow.apache.org/).\\n\\n### Implementation 3: [Apache Arrow](https://arrow.apache.org/)\\n\\nApache Arrow is a universal memory format available in many languages. \\n\\nThe same function in `arrow` would look like this:\\n```rust \\n#[pyfunction]\\nfn create_list_arrow(py: Python, a: &PyAny) -> PyResult> {\\n let arraydata = arrow::array::ArrayData::from_pyarrow(a).unwrap();\\n\\n let buffer = arraydata.buffers()[0].as_slice();\\n let len = buffer.len();\\n\\n // Zero Copy Buffer reference counted\\n let arc_s = Arc::new(buffer.to_vec());\\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).unwrap();\\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\\n let output = arrow::array::ArrayData::try_new(\\n arrow::datatypes::DataType::UInt8,\\n len,\\n None,\\n 0,\\n vec![raw_buffer],\\n vec![],\\n )\\n .unwrap();\\n\\n output.to_pyarrow(py)\\n}\\n\\n```\\n\\n\\n#### > Same list returns in **33 milliseconds** . That\'s **2x** better than `PyBytes` :racehorse::racehorse: \\n\\n\\nThis is due to having zero copy when sending back the result. The zero-copying is safe because we are reference-counting the array. The array will be deallocating once all reference has been removed. \\n\\nThe benefits of `arrow` is:\\n- to make zero-copy achievable, scaling better with bigger data.\\n- being reusable in other languages. We only have to replace the last line of the function with the export to the other languages. \\n- having many types description including `List`,`Mapping` and `Struct`.\\n- being directly usable in `numpy`, `pandas`, and `pytorch` with zero-copy transmutation.\\n\\n## Debugging\\n\\nDealing with efficient Interface is not the only challenge of bridging multiple languages. We also have to deal with cross-language debugging. \\n\\n### `.unwrap()`\\n\\nOur current implementation uses `.unwrap()`. However, this will panic the whole Python process if there is an error. \\n\\n#### > Example error:\\n```bash\\nthread \'\' panicked at \'called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError(\'Expected instance of pyarrow.lib.Array, got builtins.int\'), traceback: None }\', src/lib.rs:45:62\\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\\nTraceback (most recent call last):\\n File \\"/home/peter/Documents/work/blogpost_ffi/test_script.py\\", line 79, in \\n array = blogpost_ffi.create_list_arrow(1)\\npyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: , value: TypeError(\'Expected instance of pyarrow.lib.Array, got builtins.int\'), traceback: None }\\n```\\n\\n### [eyre](https://github.com/eyre-rs/eyre)\\n\\nEyre is an easy idiomatic error handling library for Rust applications. We can use eyre by wrapping our `pyo3` project with the `pyo3/eyre` feature flag, to replace all our `.unwrap()` with a `.context(\\"our context\\")?`. This will transform unrecoverable errors into recoverable Python errors while giving details about our errors.\\n\\n#### > Same error as above but with `eyre` which gives a better looking error message:\\n```bash\\nCould not convert arrow data\\n\\nCaused by:\\n TypeError: Expected instance of pyarrow.lib.Array, got builtins.int\\n\\nLocation:\\n src/lib.rs:75:50\\n```\\n\\nImplementation details:\\n```rust\\n#[pyfunction]\\nfn create_list_arrow_eyre(py: Python, a: &PyAny) -> Result> {\\n let arraydata =\\n arrow::array::ArrayData::from_pyarrow(a).context(\\"Could not convert arrow data\\")?;\\n\\n let buffer = arraydata.buffers()[0].as_slice();\\n let len = buffer.len();\\n\\n // Zero Copy Buffer reference counted\\n let arc_s = Arc::new(buffer.to_vec());\\n let ptr = NonNull::new(arc_s.as_ptr() as *mut _).context(\\"Could not create pointer\\")?;\\n let raw_buffer = unsafe { arrow::buffer::Buffer::from_custom_allocation(ptr, len, arc_s) };\\n let output = arrow::array::ArrayData::try_new(\\n arrow::datatypes::DataType::UInt8,\\n len,\\n None,\\n 0,\\n vec![raw_buffer],\\n vec![],\\n )\\n .context(\\"could not create arrow arraydata\\")?;\\n\\n output\\n .to_pyarrow(py)\\n .context(\\"Could not convert to pyarrow\\")\\n}\\n\\n```\\n\\n### Python traceback with `eyre`\\n\\nI will mention that you might lose the Python traceback error when calling Python code from a Rust code.\\n\\nI recommend using the following custom traceback method to have a descriptive error:\\n```rust\\n#[pyfunction]\\nfn call_func_eyre(py: Python, func: Py) -> Result<()> { \\n let _call_python = func.call0(py).context(\\"function called failed\\")?;\\n Ok(())\\n}\\n\\nfn traceback(err: pyo3::PyErr) -> eyre::Report {\\n let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok()));\\n if let Some(traceback) = traceback {\\n eyre::eyre!(\\"{traceback}\\\\n{err}\\")\\n } else {\\n eyre::eyre!(\\"{err}\\")\\n }\\n}\\n\\n#[pyfunction]\\nfn call_func_eyre_traceback(py: Python, func: Py) -> Result<()> {\\n let _call_python = func\\n .call0(py)\\n .map_err(traceback) // this will gives python traceback.\\n .context(\\"function called failed\\")?;\\n Ok(())\\n}\\n```\\n\\n#### > Example error with no custom traceback:\\n\\n```\\n---Eyre no traceback---\\neyre no traceback says: function called failed\\n\\nCaused by:\\n AssertionError: I have no idea what is wrong\\n\\nLocation:\\n src/lib.rs:89:39\\n------\\n```\\n\\n#### > Better errors with custom traceback:\\n\\n```\\n---Eyre traceback---\\neyre traceback says: function called failed\\n\\nCaused by:\\n Traceback (most recent call last):\\n File \\"/home/peter/Documents/work/blogpost_ffi/test_script.py\\", line 96, in abc\\n assert False, \\"I have no idea what is wrong\\"\\n\\n AssertionError: I have no idea what is wrong\\n\\nLocation:\\n src/lib.rs:96:9\\n------\\n```\\n\\nWith the traceback, we can quickly identify the root error. \\n\\n## Memory management\\n\\nLet\'s take another example, and imagine that we need to create arrays within a loop:\\n\\n```rust\\n/// Unbounded memory growth\\n#[pyfunction]\\nfn unbounded_memory_growth(py: Python) -> Result<()> {\\n for _ in 0..10 {\\n let a: Vec = vec![0; 40_000_000];\\n let _ = PyBytes::new(py, &a);`\\n \\n std::thread::sleep(Duration::from_secs(1));\\n }\\n\\n Ok(())\\n```\\n\\n#### > Calling this function will consume 440MB of memory. :-1: \\n\\nWhat happened is that `pyo3` memory model keeps all Python variables in memory until the GIL is released.\\n\\nTherefore, if we create variables in a `pyfunction` loop, all temporary variables are going to be kept until the GIL is released. \\n\\nThis is due to `pyfunction` locking the GIL by default.\\n\\nBy understanding the GIL-based memory model, we can use a scoped GIL to have the expected behaviour:\\n\\n```rust\\n#[pyfunction]\\nfn bounded_memory_growth(py: Python) -> Result<()> {\\n py.allow_threads(|| {\\n for _ in 0..10 {\\n Python::with_gil(|py| {\\n let a: Vec = vec![0; 40_000_000];\\n let _bytes = PyBytes::new(py, &a);\\n \\n std::thread::sleep(Duration::from_secs(1));\\n });\\n }\\n });\\n\\n // or\\n \\n for _ in 0..10 {\\n let pool = unsafe { py.new_pool() };\\n let py = pool.python();\\n\\n let a: Vec = vec![0; 40_000_000];\\n let _bytes = PyBytes::new(py, &a);\\n\\n std::thread::sleep(Duration::from_secs(1));\\n }\\n\\n Ok(())\\n}\\n```\\n\\n#### > Calling this function will consume 80MB of memory. :thumbsup: \\n\\n> [More info can be found here](https://pyo3.rs/main/memory.html#gil-bound-memory)\\n\\n> [Possible fix in Pyo3 0.21!](https://github.com/PyO3/pyo3/issues/3382)\\n>\\n\\n## Race condition\\n\\nLet\'s take another example, and imagine that we need to process data in different threads:\\n\\n```rust\\n/// Function GIL Lock\\n#[pyfunction]\\nfn gil_lock() {\\n let start_time = Instant::now();\\n std::thread::spawn(move || {\\n Python::with_gil(|py| println!(\\"This threaded print was printed after {:#?}\\", &start_time.elapsed()));\\n });\\n\\n std::thread::sleep(Duration::from_secs(10));\\n}\\n```\\n\\n#### > This threaded print was printed after 10.0s. :cry: \\n\\nWhen using Python with `pyo3`, we have to make sure to know exactly when the GIL is locked or unlocked to avoid race conditions. \\n\\nIn the example above, the issue is that by default `pyo3` is going to lock the GIL in the main function thread, therefore blocking the spawned thread that is waiting for the GIL.\\n\\nIf we use the GIL in the main function thread or release the GIL in the main function thread, there is no issue.\\n\\n```rust\\n/// No gil lock\\n#[pyfunction]\\nfn gil_unlock() {\\n let start_time = Instant::now();\\n std::thread::spawn(move || {\\n std::thread::sleep(Duration::from_secs(10));\\n });\\n\\n Python::with_gil(|py| println!(\\"1. This was printed after {:#?}\\", &start_time.elapsed()));\\n\\n // or\\n\\n let start_time = Instant::now();\\n std::thread::spawn(move || {\\n Python::with_gil(|py| println!(\\"2. This was printed after {:#?}\\", &start_time.elapsed()));\\n });\\n Python::with_gil(|py| {\\n py.allow_threads(|| {\\n std::thread::sleep(Duration::from_secs(10));\\n })\\n });\\n}\\n```\\n#### > \\"1\\" was printed after 32\xb5s and \\"2\\" was printed after 80\xb5s, so there was no race condition. :smile: \\n\\n## Tracing\\n\\nAs we can see, being able to measure the time spent when interfacing can be very valuable to identify bottlenecks. \\n\\nBut measuring the time spent manually as we did before can be tedious. \\n\\nWhat we can do is use a tracing library to do it for us. [Opentelemetry](https://opentelemetry.io/) can help us build a distributed observable system capable of bridging multiple languages. [Opentelemetry](https://opentelemetry.io/) can be used for tracing, metrics and logs.\\n\\nFor example, if we add:\\n```rust \\n/// No gil lock\\n#[pyfunction]\\nfn global_tracing(py: Python, func: Py) {\\n // global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());\\n global::set_text_map_propagator(TraceContextPropagator::new());\\n\\n // Connect to Jaeger Opentelemetry endpoint\\n // Start a new endpoint with:\\n // docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest\\n let _tracer = opentelemetry_jaeger::new_agent_pipeline()\\n .with_endpoint(\\"172.17.0.1:6831\\")\\n .with_service_name(\\"rust_ffi\\")\\n .install_simple()\\n .unwrap();\\n\\n let tracer = global::tracer(\\"test\\");\\n\\n // Parent Trace, first trace\\n let _ = tracer.in_span(\\"parent_python_work\\", |cx| -> Result<()> { \\n std::thread::sleep(Duration::from_secs(1));\\n \\n let mut map = HashMap::new();\\n global::get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut map));\\n\\n let output = func\\n .call1(py, (map,))\\n .map_err(traceback)\\n .context(\\"function called failed\\")?;\\n let out_map: HashMap = output.extract(py).unwrap();\\n let out_context = global::get_text_map_propagator(|prop| prop.extract(&out_map));\\n\\n std::thread::sleep(Duration::from_secs(1));\\n\\n let _span = tracer.start_with_context(\\"after_python_work\\", &out_context); // third trace\\n\\n Ok(())\\n });\\n}\\n```\\n\\n\\nAnd the following, in the Python code:\\n```python\\ndef abc(cx):\\n propagator = TraceContextTextMapPropagator()\\n context = propagator.extract(carrier=cx)\\n\\n with tracing.tracer.start_as_current_span(\\n name=\\"Python_span\\", context=context\\n ) as child_span:\\n child_span.add_event(\\"in Python!\\")\\n output = {}\\n tracing.propagator.inject(output)\\n time.sleep(2)\\n return output\\n```\\n\\nWe will get the following traces:\\n\\n![](/img/blogpost_ffi.png)\\n\\nUsing this we can measure the time spent when interfacing languages, identify lock issues, and with the combination of logs and metrics, reduce the complexity of multi-language libraries.\\n\\n# [dora-rs](https://github.com/dora-rs/dora)\\n\\nHopefully, this small blog post should help you identify FFI issues. \\n\\nAll optimization above have already been implemented within [dora-rs](https://github.com/dora-rs/dora) that lets you build fast and simple dataflows using Rust, Python, C and C++.\\n\\nYou\'re very welcome to check out [dora-rs](https://github.com/dora-rs/dora) if bridging languages in a dataflow is your usecase.\\n\\nWe just recently opened a Discord and you can reach out there for literally any question, even just for a quick chat: https://discord.gg/DXJ6edAtym\\n\\nI\'m also going to present this FFI work at [GOSIM Workshop in Shanghai on the 23rd of Sept 2023](https://workshop2023.gosim.org/schedule#auto)!\\n\\nFor more info on `dora-rs`:\\n- Github: https://github.com/dora-rs/dora\\n- Website: https://www.dora-rs.ai/\\n- Discord: https://discord.gg/XqhQaN8P"}]}')}}]); \ No newline at end of file diff --git a/assets/js/dd05a678.a0a4af3a.js b/assets/js/dd05a678.00795e33.js similarity index 89% rename from assets/js/dd05a678.a0a4af3a.js rename to assets/js/dd05a678.00795e33.js index 273cc2dc..26f08753 100644 --- a/assets/js/dd05a678.a0a4af3a.js +++ b/assets/js/dd05a678.00795e33.js @@ -1 +1 @@ -"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[2394],{80756:(t,e,o)=>{o.r(e),o.d(e,{assets:()=>d,contentTitle:()=>n,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var s=o(74848),a=o(28453),i=o(96630);const r={sidebar_position:1},n="Search",l={id:"nodes/readme",title:"Search",description:"",source:"@site/docs/nodes/readme.mdx",sourceDirName:"nodes",slug:"/nodes/",permalink:"/docs/nodes/",draft:!1,unlisted:!1,editUrl:"https://github.com/dora-rs/dora-rs.github.io/edit/main/docs/nodes/readme.mdx",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1},sidebar:"nodes",next:{title:"Search",permalink:"/docs/nodes/"}},d={},c=[];function p(t){const e={h1:"h1",...(0,a.R)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.h1,{id:"search",children:"Search"}),"\n","\n",(0,s.jsx)(i.KE,{})]})}function h(t={}){const{wrapper:e}={...(0,a.R)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(p,{...t})}):p(t)}},96630:(t,e,o)=>{o.d(e,{KE:()=>nt,Ay:()=>lt,Ed:()=>$});var s=o(96540),a=o(20053),i=o(38193),r=o(21312),n=o(56347),l=o(53465),d=o(28774);const c={svgIcon:"svgIcon_R3jO",small:"small_SUAn",medium:"medium_GxVq",large:"large_TyPU",primary:"primary_V8Cc",secondary:"secondary_WyIo",success:"success_lY5U",error:"error_eHdq",warning:"warning_IB04",inherit:"inherit_2ln5"};var p=o(74848);function h(t){const{svgClass:e,colorAttr:o,children:s,color:i="inherit",size:r="medium",viewBox:n="0 0 24 24",...l}=t;return(0,p.jsx)("svg",{viewBox:n,color:o,"aria-hidden":!0,className:(0,a.A)(c.svgIcon,c[i],c[r],e),...l,children:s})}function m(t){return(0,p.jsx)(h,{...t,children:(0,p.jsx)("path",{d:"M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"})})}function u(t,e){const o=[...t];return o.sort(((t,o)=>e(t)>e(o)?1:e(o)>e(t)?-1:0)),o}const g=JSON.parse('[{"title":"Yolov5 Operator","description":"Yolov5 object detection operator","preview":"https://i.imgur.com/hPrazyl.jpg","website":"yolov5_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolov5_op.py","tags":["cv","python"]},{"title":"Plot Operator","description":"Plot operator based on cv2","preview":"https://i.imgur.com/ekEgDL5.png","website":"plot_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/plot.py","tags":["python"]},{"title":"PID Operator","description":"PID controller","preview":"https://i.imgur.com/AEmoZ7k.gif","website":"pid_control_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/pid_control_op.py","tags":["python","control"]},{"title":"Obstacle Location Operator","description":"Obstacle location based on LIDAR and 2D bounding boxes","preview":"https://i.imgur.com/Aq33qy5.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/obstacle_location_op.py","tags":["python"]},{"title":"FOT Operator","description":"Waypoint generation based on current position and frenet optimal trajectory planner.","preview":"https://i.imgur.com/klQitzg.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/fot_op.py","tags":["python"]},{"title":"YOLOP Operator","description":"YOLOP lane and drivable area detection","preview":"https://i.imgur.com/I531NIT.gif","website":"yolop_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolop_op.py","tags":["cv","python"]},{"title":"MiDaS Operator","description":"MiDaS depth estimation","preview":"https://i.imgur.com/UrF9iPN.png","website":"midas_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/midas_op.py","tags":["depth_estimation","python"]},{"title":"Webcam Operator","description":"Webcam Operator","preview":"https://i.imgur.com/CC0IW3i.png","website":"webcam_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/webcam_op.py","tags":["python"]},{"title":"Strong Sort Operator","description":"Strong Sort Operator","preview":"https://i.imgur.com/ozO1y7l.gif","website":"strong_sort_op","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/strong_sort_op.py","tags":["cv","python"]}]');var b=o.t(g,2);const y=JSON.parse('[{"title":"Speech to Text","description":"Transform speech to text.","preview":"/img/whisper.png.avif","website":"stt","source":"https://github.com/dora-rs/dora/blob/main/examples/speech-to-text","tags":["audio","python"],"category":"Audio","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fspeech-to-text"},{"title":"Translation","description":"Translate audio in real time.","website":"translation","source":"https://github.com/dora-rs/dora/blob/main/examples/translation","tags":["audio","python"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Ftranslation","category":"Audio"},{"title":"Vision Language Model","description":"Use a VLM to understand images.","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"vlm","source":"https://github.com/dora-rs/dora/blob/main/examples/vlm","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fvlm","tags":["python","image"],"category":"Vision"},{"title":"YOLO","description":"Use YOLO to detect object within image.","preview":"https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-banner.avif","website":"yolo","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":["python","image"],"category":"Vision"},{"title":"Camera","description":"Simple webcam plot example","preview":"https://upload.wikimedia.org/wikipedia/commons/3/35/AdventWebcam.jpg","website":"webcam","source":"https://github.com/dora-rs/dora/blob/main/examples/camera","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcamera","tags":["python","image"],"category":"Vision"},{"title":"Piper RDT","description":"Piper RDT Pipeline","website":"piper","source":"https://github.com/dora-rs/dora/blob/main/examples/piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpiper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","tags":["python","image"],"category":"Training"},{"title":"LeRobot - Alexander Koch","description":"Piper RDT Pipeline","website":"lerobot","source":"https://raw.githubusercontent.com/dora-rs/dora-lerobot/refs/heads/main/README.md","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-lerobot","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","tags":["python","image"],"category":"Training"},{"title":"C Example","description":"Example with C node","website":"c-example","preview":"https://iq.direct/images/C-programming.png","source":"https://github.com/dora-rs/dora/blob/main/examples/c-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ Example","description":"Example with C++ node","website":"c++-example","preview":"https://repository-images.githubusercontent.com/124365799/7d888300-6a39-11ea-9025-fd5574f062c7","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-dataflow","tags":[],"category":"Tutorial"},{"title":"CMake Example","description":"Example using CMake","website":"cmake-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ-IsFXHxaLnZWam5sEJvnUZAzGMyGzXfOKMmIX9XeugcL45yTIuizNbaYi4Y-obbI14A&usqp=CAU","source":"https://github.com/dora-rs/dora/blob/main/examples/cmake-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcmake-dataflow","tags":[],"category":"Tutorial"},{"title":"CUDA Example","description":"Example using CUDA Zero Copy","website":"cuda-example","preview":"https://d29g4g2dyqv443.cloudfront.net/sites/default/files/akamai/ros-dp-nitros.gif","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Tutorial"},{"title":"Rust Example","description":"Example using Rust","website":"rust-example","preview":"https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-light.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-dataflow","tags":[],"category":"Tutorial"},{"title":"Python Example","description":"Example using Python","website":"python-example","preview":"https://upload.wikimedia.org/wikipedia/commons/f/f8/Python_logo_and_wordmark.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":[],"category":"Tutorial"},{"title":"Python ROS2 Example","description":"Example using Python ROS2","website":"python-ros2-example","preview":"https://www.aranacorp.com/wp-content/uploads/python-ros2.png","source":"https://github.com/dora-rs/dora/blob/main/examples/python-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"Rust ROS2 Example","description":"Example using Rust ROS2","website":"rust-ros2-example","preview":"https://robonomics.network/assets/static/cover.d57b2e8.268586f3596831daf0d2d0fa2c885458.jpg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ ROS2 Example","description":"Example using C++ ROS2","website":"c++-ros2-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSnC1cXYAAjFUjNAogVCAr8HrAmumbx9nEnhg&s","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"CPU Benchmark","description":"CPU Benchmark of dora-rs","website":"cpu-benchmark","preview":"https://github.com/user-attachments/assets/3285d183-7560-40e1-ac02-30fee0f120cb","source":"https://github.com/dora-rs/dora-benchmark/blob/main","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-benchmark","tags":[],"category":"Benchmark"},{"title":"GPU Benchmark","description":"GPU Benchmark of dora-rs","website":"gpu-benchmark","preview":"https://github.com/user-attachments/assets/d64370fc-b0ba-46af-be83-19d3c772ada6","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Benchmark"}]');var w=o.t(y,2);const v=JSON.parse('[{"title":"Whisper","description":"Transcribe audio to text","preview":"/img/whisper.png.avif","website":"whisper","github":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-distil-whisper","install":"- id: dora-distil-whisper\\n build: pip install dora-distil-whisper\\n path: dora-distil-whisper\\n inputs: \\n tick: /audio\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-distil-whisper","last_release":"https://img.shields.io/pypi/v/dora-distil-whisper","license":"https://img.shields.io/pypi/l/dora-distil-whisper","category":"Speech to Text"},{"title":"Qwenvl","description":"Vision Language Model","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"qwenvl","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-qwenvl","install":"- id: dora-qwenvl\\n build: pip install dora-qwenvl\\n path: dora-qwenvl\\n inputs: \\n text: /text\\n image: /image\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-qwenvl","tags":["python","image","text"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-qwenvl","last_release":"https://img.shields.io/pypi/v/dora-qwenvl","license":"https://img.shields.io/pypi/l/dora-qwenvl","category":"Vision Language Model"},{"title":"Silero VAD","description":"Silero Voice activity detection","preview":"https://user-images.githubusercontent.com/12515440/89997349-b3523080-dc94-11ea-9906-ca2e8bc50535.png","website":"silero","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-vad","install":"- id: dora-vad\\n build: pip install dora-vad\\n path: dora-vad\\n inputs: \\n tick: /audio\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-vad","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-vad","last_release":"https://img.shields.io/pypi/v/dora-vad","license":"https://img.shields.io/pypi/l/dora-vad","category":"Voice Activity Detection"},{"title":"Microphone","description":"Audio from microphone","author":"dora","website":"microphone","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8EPOj0PAu4yyERZg4ncm-vMgBqaU5lSP6_Q&s","downloads":"https://img.shields.io/pypi/dm/dora-microphone","install":"- id: dora-microphone\\n build: pip install dora-microphone\\n path: dora-microphone\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-microphone","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-microphone","last_release":"https://img.shields.io/pypi/v/dora-microphone","license":"https://img.shields.io/pypi/l/dora-microphone","category":"Peripheral"},{"title":"Rerun","description":"Visualization tool","author":"dora","website":"rerun","downloads":"https://img.shields.io/pypi/dm/dora-rerun","install":"- id: dora-rerun\\n build: pip install dora-rerun\\n path: dora-rerun\\n inputs: \\n image: /image\\n text: /text","preview":"https://user-images.githubusercontent.com/1148717/218141237-0442d2b5-ed22-42bf-9321-10af1b894507.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rerun","tags":["rust","text","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rerun","last_release":"https://img.shields.io/pypi/v/dora-rerun","license":"https://img.shields.io/pypi/l/dora-rerun","category":"Visualization"},{"title":"Video Capture","description":"Image stream from Camera","author":"dora","website":"opencv-video-capture","install":"- id: opencv-video-capture\\n build: pip install opencv-video-capture\\n path: opencv-video-capture\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image","downloads":"https://img.shields.io/pypi/dm/opencv-video-capture","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-video-capture","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-video-capture","last_release":"https://img.shields.io/pypi/v/opencv-video-capture","license":"https://img.shields.io/pypi/l/opencv-video-capture","tags":["python","image"],"category":"Camera"},{"title":"Yolov8","description":"Object detection","author":"dora","website":"yolo","install":"- id: dora-yolo\\n build: pip install dora-yolo\\n path: dora-yolo\\n inputs: \\n image: /image\\n outputs: \\n - bbox","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-yolo","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-yolo","last_release":"https://img.shields.io/pypi/v/dora-yolo","license":"https://img.shields.io/pypi/l/dora-yolo","tags":["python","image"],"category":"Object Detection"},{"title":"Plot","description":"Simple OpenCV plot visualization","author":"dora","website":"opencv-plot","install":"- id: opencv-plot\\n build: pip install opencv-plot\\n path: opencv-plot\\n inputs: \\n image: /image\\n text: /text","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-plot","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-plot","last_release":"https://img.shields.io/pypi/v/opencv-plot","license":"https://img.shields.io/pypi/l/opencv-plot","tags":["python","image","text"],"category":"Visualization"},{"title":"PyRealsense","description":"Image and depth from Realsense","author":"dora","website":"pyrealsense","install":"- id: dora-pyrealsense\\n build: pip install dora-pyrealsense\\n path: dora-pyrealsense\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth","downloads":"https://img.shields.io/pypi/dm/dora-pyrealsense","preview":"https://user-images.githubusercontent.com/41145062/193884336-c30397be-2cac-45da-ba34-07e7db9843e8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyrealsense","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyrealsense","last_release":"https://img.shields.io/pypi/v/dora-pyrealsense","license":"https://img.shields.io/pypi/l/dora-pyrealsense","tags":["python","image","depth"],"category":"Camera"},{"title":"PyOrbbeckSDK","description":"Image and depth from Orbbeck Camera","author":"dora","website":"pyorbbecsdk","install":"- id: dora-pyorbbecksdk\\n build: pip install dora-pyorbbecksdk\\n path: dora-pyorbbecksdk\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth\\n - image_depth","downloads":"https://img.shields.io/pypi/dm/dora-pyorbbecksdk","preview":"https://new-orbbec3d-s3.s3.amazonaws.com/wp-content/uploads/2024/06/03120334/\u53f345\u5ea6-e1717416268437-300x153.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyorbbecksdk","tags":["python","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyorbbecksdk","last_release":"https://img.shields.io/pypi/v/dora-pyorbbecksdk","license":"https://img.shields.io/pypi/l/dora-pyorbbecksdk","category":"Camera"},{"title":"Keyboard","description":"Keyboard char listener","author":"dora","website":"keyboard","install":"- id: dora-keyboard\\n build: pip install dora-keyboard\\n path: dora-keyboard\\n inputs: \\n tick: dora/timer/millis/1000\\n outputs: \\n - char","downloads":"https://img.shields.io/pypi/dm/dora-keyboard","preview":"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/LenovoKeyboard.jpg/220px-LenovoKeyboard.jpg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-keyboard","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-keyboard","last_release":"https://img.shields.io/pypi/v/dora-keyboard","license":"https://img.shields.io/pypi/l/dora-keyboard","tags":["python","text"],"category":"Peripheral"},{"title":"Agilex - Piper","description":"Agilex arm client","author":"dora","website":"piper","install":"- id: dora-piper\\n build: pip install dora-piper\\n path: dora-piper\\n inputs: \\n tick: dora/timer/millis/20\\n joint_action: /jointstate\\n outputs: \\n - jointstate","downloads":"https://img.shields.io/pypi/dm/dora-piper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-piper","last_release":"https://img.shields.io/pypi/v/dora-piper","license":"https://img.shields.io/pypi/l/dora-piper","tags":["python"],"category":"Arm"},{"title":"Opus MT","description":"Translate text between language","author":"dora","website":"opus","install":"- id: dora-opus\\n build: pip install dora-opus\\n path: dora-opus\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","downloads":"https://img.shields.io/pypi/dm/dora-opus","preview":"https://github.com/Helsinki-NLP/Opus-MT/raw/master/img/opus_mt.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-opus","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-opus","last_release":"https://img.shields.io/pypi/v/dora-opus","license":"https://img.shields.io/pypi/l/dora-opus","tags":["python","text"],"category":"Translation"},{"title":"Llama Factory Recorder","description":"Record data to train LLM and VLM","author":"dora","website":"llama-factory-recorder","install":"- id: llama-factory-recorder\\n build: pip install llama-factory-recorder\\n path: llama-factory-recorder\\n inputs: \\n image: /image\\n text: /text\\n ground_truth: /text\\n outputs: \\n - text","downloads":"https://img.shields.io/pypi/dm/llama-factory-recorder","preview":"https://github.com/hiyouga/LLaMA-Factory/blob/main/assets/logo.png?raw=true","source":"https://github.com/dora-rs/dora/blob/main/node-hub/llama-factory-recorder","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fllama-factory-recorder","last_release":"https://img.shields.io/pypi/v/llama-factory-recorder","license":"https://img.shields.io/pypi/l/llama-factory-recorder","tags":["python","image","text"],"category":"Recorder"},{"title":"RDT-1B","description":"Infer policy using Robotic Diffusion Transformer","author":"dora","website":"rdt","install":"- id: dora-rdt-1b\\n build: pip install dora-rdt-1b\\n path: dora-rdt-1b\\n inputs: \\n image: /image\\n jointstate: /jointstate\\n outputs: \\n - action","downloads":"https://img.shields.io/pypi/dm/dora-rdt-1b","preview":"https://github.com/thu-ml/RoboticsDiffusionTransformer/raw/main/assets/head.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rdt-1b","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rdt-1b","last_release":"https://img.shields.io/pypi/v/dora-rdt-1b","license":"https://img.shields.io/pypi/l/dora-rdt-1b","tags":["python","image","text"],"category":"Vision Language Action"},{"title":"Dynamixel","description":"Dynamixel Client","author":"Enzo Levan","website":"dynamixel","preview":"https://robots.ros.org/assets/img/robots/dynamixel/dynamixel.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dynamixel-client","tags":["python"],"category":"Actuator"},{"title":"Feetech","description":"Feetech Client","author":"Enzo Levan","website":"feetech","preview":"https://media.licdn.com/dms/image/v2/C5612AQGpeiwwIPDqaw/article-cover_image-shrink_720_1280/article-cover_image-shrink_720_1280/0/1647414552058?e=2147483647&v=beta&t=QoHYcvm7pla6ptYtg3daKPAGRRctKGEkIGkBrGyE25Y","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/feetech-client","tags":["python"],"category":"Actuator"},{"title":"Mujoco","description":"Mujoco Simulator","author":"Enzo Levan","website":"mujoco","preview":"https://github.com/google-deepmind/mujoco/raw/main/banner.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/mujoco-client","tags":["python"],"category":"Simulator"},{"title":"Lebai - LM3","description":"Lebai client","author":"dora","website":"lebai","preview":"https://l-www.lebai.ltd/2015/07/1-495x400.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lebai-client","tags":["python"],"category":"Arm"},{"title":"Alex Koch - Low Cost Robot","description":"Alex Koch - Low Cost Robot Client","author":"dora","website":"alex-koch-low-cost-robot","preview":"https://github.com/AlexanderKoch-Koch/low_cost_robot/raw/main/pictures/robot_portait.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/alexk-lcr","tags":["python"],"category":"Arm"},{"title":"Trossen - Aloha","description":"Aloha client","author":"dora","website":"aloha","preview":"https://static.wixstatic.com/media/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg/v1/fill/w_1000,h_659,al_c,q_85,usm_0.66_1.00_0.01/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/aloha","tags":["python"],"category":"Robot"},{"title":"Pollen - Reachy 2","description":"Reachy 2 client","author":"dora","website":"reachy2","preview":"https://www.lejournaldesentreprises.com/sites/lejournaldesentreprises.com/files/styles/landscape_web_lg_1x/public/2024-11/Reachy-2-sait-reprer-un-objet-le-saisir-et-le-m-15512511.jpeg?itok=syrnHhWx","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/reachy","tags":["python"],"category":"Robot"},{"title":"Carla","description":"Carla Simulator","author":"dora","website":"carla","preview":"https://media.licdn.com/dms/image/v2/D4D1BAQHyb4EFail-wQ/company-background_10000/company-background_10000/0/1663774857825/carla_simulator_cover?e=2147483647&v=beta&t=AmftWPQMtfni1t_RXUvqqkQJqxKK_I54BoHpLLSwjWE","source":"https://github.com/dora-rs/dora-drives","tags":["python"],"category":"Simulator"},{"title":"Pollen - Reachy 1","description":"Reachy 1 Client","author":"dora","website":"reachy1","install":"- id: dora-reachy1\\n build: pip install dora-reachy1\\n path: dora-reachy1","preview":"https://www.aquitaineonline.com/images/stories/Economie_Industrie_2021/Reachy_01.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dora-reachy1","tags":["python"],"category":"Robot"},{"title":"DJI - Robomaster S1","description":"Robomaster Client","author":"dora","website":"robomaster-s1","preview":"https://m.media-amazon.com/images/I/61K2UXjfHwL.jpg","source":"https://huggingface.co/datasets/dora-rs/dora-robomaster","tags":["python"],"category":"Chassis"},{"title":"Agilex - UGV","description":"Robomaster Client","author":"dora","website":"robomaster-s1","downloads":"https://img.shields.io/pypi/dm/dora-ugv","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvTwJ589Zudgva9TIQ79ddJ8wHUq2_jmrUZg&s","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-ugv","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-ugv","last_release":"https://img.shields.io/pypi/v/dora-ugv","license":"https://img.shields.io/pypi/l/dora-ugv","tags":["python"],"category":"Chassis"},{"title":"Dora Kit Car","description":"Open Source Chassis","author":"dora","website":"dora-kit-car","downloads":"https://img.shields.io/pypi/dm/dora-kit-car","preview":"https://github.com/RuPingCen/mick_robot_chassis/raw/master/README.assets/fengmian.gif","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-kit-car","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-kit-car","last_release":"https://img.shields.io/pypi/v/dora-kit-car","license":"https://img.shields.io/pypi/l/dora-kit-car","tags":["python"],"category":"Chassis"},{"title":"ArgosTranslate","description":"Open Source translation engine","author":"dora","website":"argotranslate","downloads":"https://img.shields.io/pypi/dm/dora-argotranslate","install":"- id: dora-argotranslate\\n build: pip install dora-argotranslate\\n path: dora-argotranslate\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","preview":"https://avatars.githubusercontent.com/u/48267258?v=4","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-argotranslate","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-argotranslate","last_release":"https://img.shields.io/pypi/v/dora-argotranslate","license":"https://img.shields.io/pypi/l/dora-argotranslate","tags":["python"],"category":"Translation"},{"title":"InternVL","description":"InternVL is a vision language model","author":"dora","website":"internvl","downloads":"https://img.shields.io/pypi/dm/dora-internvl","preview":"https://private-user-images.githubusercontent.com/23737120/379689418-930e6814-8a9f-43e1-a284-118a5732daa4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYzNDcwODEsIm5iZiI6MTczNjM0Njc4MSwicGF0aCI6Ii8yMzczNzEyMC8zNzk2ODk0MTgtOTMwZTY4MTQtOGE5Zi00M2UxLWEyODQtMTE4YTU3MzJkYWE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA4VDE0MzMwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3YTUyM2UyMDc5ZmMxNjk5NWZmNzg4ZjgxN2VkNzIyOTFmYjc2OGJiZGJlOWQ1Y2Q4NWU2OTJhYmRjMzZhZjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uiWkdjPEgeUJkiCVNii9Huh4M1ykJ2Cm_FVcTDcldYs","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-internvl","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-internvl","last_release":"https://img.shields.io/pypi/v/dora-internvl","license":"https://img.shields.io/pypi/l/dora-internvl","tags":["python"],"category":"Vision Language Model"},{"title":"LeRobot Recorder","description":"LeRobot Recorder helper","author":"dora","website":"lerobot-dashboard","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lerobot-dashboard","tags":["python"],"category":"Recorder"},{"title":"Gymnasium","description":"Experimental OpenAI Gymnasium bridge","author":"dora","website":"gymnasium","preview":"https://raw.githubusercontent.com/Farama-Foundation/Gymnasium/main/gymnasium-text.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/gym_dora","tags":["python"],"category":"Simulator"}]');var x=o.t(v,2);const f=["Camera","Peripheral","Actuator","Chassis","Arm","Robot","Voice Activity Detection","Speech to Text","Object Detection","Vision Language Model","Large Language Model","Vision Language Action","Translation","Text to Speech","Recorder","Visualization","Simulator"],_=["Audio","Vision","Training","Tutorial","Benchmark"],j={image:{label:(0,r.T)({id:"showcase.tag.image.tag",message:"image"}),description:(0,r.T)({message:"Computer vision related nodes!",id:"showcase.tag.image.description"}),color:"#39ca30"},python:{label:(0,r.T)({id:"showcase.tag.python.tag",message:"python"}),description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.python.description"}),color:"#dfd545"},rust:{label:"rust",description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.rust.description"}),color:"#333e2e"},control:{label:(0,r.T)({id:"showcase.tag.control.tag",message:"control"}),description:(0,r.T)({message:"Beautiful Docusaurus sites, polished and standing out from the initial template!",id:"showcase.tag.control.description"}),color:"#a44fb7"},depth:{label:(0,r.T)({id:"showcase.tag.depth.tag",message:"depth"}),description:(0,r.T)({message:"Translated Docusaurus sites using the internationalization support with more than 1 locale.",id:"showcase.tag.depth.description"}),color:"#127f82"},audio:{label:(0,r.T)({message:"audio"}),description:(0,r.T)({message:"Docusaurus sites using the versioning feature of the docs plugin to manage multiple versions.",id:"showcase.tag.audio.description"}),color:"#fe6829"},text:{label:(0,r.T)({message:"text"}),description:(0,r.T)({message:"Very large Docusaurus sites, including many more pages than the average!",id:"showcase.tag.large.description"}),color:"#8c2f00"}},k=Object.keys(j),C=b,E=w,L=x;!function(){let t=C.default;t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite")))}();const N=function(){let t=E.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();const A=function(){let t=L.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();var T=o(51107);const O="checkboxLabel_0lFL",F="tags";function R(t){return new URLSearchParams(t).getAll(F)}function S(t,e){let{id:o,icon:a,label:i,tag:r,...l}=t;const d=(0,n.zy)(),c=(0,n.W6)(),[h,m]=(0,s.useState)(!1);(0,s.useEffect)((()=>{const t=R(d.search);m(t.includes(r))}),[r,d]);const u=(0,s.useCallback)((()=>{const t=function(t,e){const o=t.indexOf(e);if(-1===o)return t.concat(e);const s=[...t];return s.splice(o,1),s}(R(d.search),r),e=function(t,e){const o=new URLSearchParams(t);return o.delete(F),e.forEach((t=>o.append(F,t))),o.toString()}(d.search,t);c.push({...d,search:e,state:$()})}),[r,d,c]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("input",{type:"checkbox",id:o,className:"screen-reader-only",onKeyDown:t=>{"Enter"===t.key&&u()},onFocus:t=>{t.relatedTarget&&t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("focus"))},onBlur:t=>{t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("blur"))},onChange:u,checked:h,...l}),(0,p.jsxs)("label",{ref:e,htmlFor:o,className:O,children:[i,a]})]})}const I=s.forwardRef(S),D={checkboxLabel:"checkboxLabel_tOkT"},M="operator";function P(t){return new URLSearchParams(t).get(M)??"OR"}function U(){const t="showcase_filter_toggle",e=(0,n.zy)(),o=(0,n.W6)(),[i,r]=(0,s.useState)(!1);(0,s.useEffect)((()=>{r("AND"===P(e.search))}),[e]);const l=(0,s.useCallback)((()=>{r((t=>!t));const t=new URLSearchParams(e.search);t.delete(M),i||t.append(M,"AND"),o.push({...e,search:t.toString(),state:$()})}),[i,e,o]);return(0,p.jsxs)("div",{children:[(0,p.jsx)("input",{type:"checkbox",id:t,className:"screen-reader-only","aria-label":"Toggle between or and and for the tags you selected",onChange:l,onKeyDown:t=>{"Enter"===t.key&&l()},checked:i}),(0,p.jsxs)("label",{htmlFor:t,className:(0,a.A)(D.checkboxLabel,"shadow--md"),children:[(0,p.jsx)("span",{className:D.checkboxLabelOr,children:"OR"}),(0,p.jsx)("span",{className:D.checkboxLabelAnd,children:"AND"})]})]})}var V=o(40961),z=o(50991);const G={tooltip:"tooltip_vy6_",tooltipArrow:"tooltipArrow_lQYZ"};function B(t){let{children:e,id:o,anchorEl:a,text:i}=t;const[r,n]=(0,s.useState)(!1),[l,d]=(0,s.useState)(null),[c,h]=(0,s.useState)(null),[m,u]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),{styles:y,attributes:w}=(0,z.E)(l,c,{modifiers:[{name:"arrow",options:{element:m}},{name:"offset",options:{offset:[0,8]}}]}),v=(0,s.useRef)(null),x=`${o}_tooltip`;return(0,s.useEffect)((()=>{b(a?"string"==typeof a?document.querySelector(a):a:document.body)}),[g,a]),(0,s.useEffect)((()=>{const t=["mouseenter","focus"],e=["mouseleave","blur"],o=()=>{""!==i&&(l?.removeAttribute("title"),v.current=window.setTimeout((()=>{n(!0)}),400))},s=()=>{clearInterval(v.current),n(!1)};return l&&(t.forEach((t=>{l.addEventListener(t,o)})),e.forEach((t=>{l.addEventListener(t,s)}))),()=>{l&&(t.forEach((t=>{l.removeEventListener(t,o)})),e.forEach((t=>{l.removeEventListener(t,s)})))}}),[l,i]),(0,p.jsxs)(p.Fragment,{children:[s.cloneElement(e,{ref:d,"aria-describedby":r?x:void 0}),g?V.createPortal(r&&(0,p.jsxs)("div",{id:x,role:"tooltip",ref:h,className:G.tooltip,style:y.popper,...w.popper,children:[i,(0,p.jsx)("span",{ref:u,className:G.tooltipArrow,style:y.arrow})]}),g):g]})}const W={showcaseCardImage:"showcaseCardImage_RonU",showcaseCardHeader:"showcaseCardHeader_DBrh",showcaseCardHeaderNoImage:"showcaseCardHeaderNoImage_I3oL",showcaseCardTitle:"showcaseCardTitle_c4K_",svgIconFavorite:"svgIconFavorite_eNhx",showcaseCardSrcBtn:"showcaseCardSrcBtn_zC6u",showcaseCardBody:"showcaseCardBody_Uq33",cardFooter:"cardFooter_jnMp",tag:"tag_rgoW",textLabel:"textLabel_Um7W",colorLabel:"colorLabel_wSaw"};var Y=o(21432);const q=s.forwardRef(((t,e)=>{let{label:o,color:s,description:a}=t;return(0,p.jsxs)("li",{ref:e,className:W.tag,title:a,children:[(0,p.jsx)("span",{className:W.textLabel,children:o.toLowerCase()}),(0,p.jsx)("span",{className:W.colorLabel,style:{backgroundColor:s}})]})}));function J(t){let{tags:e}=t;const o=u(e.map((t=>({tag:t,...j[t]}))),(t=>k.indexOf(t.tag)));return(0,p.jsx)(p.Fragment,{children:o.map(((t,e)=>{const o=`showcase_card_tag_${t.tag}`;return(0,p.jsx)(B,{text:t.description,anchorEl:"#__docusaurus",id:o,children:(0,p.jsx)(q,{...t},e)},e)}))})}function Z(t){let{user:e}=t;!function(t){t.preview}(e);const o=e.source;return(0,p.jsxs)("li",{className:"card shadow--md",children:[(0,p.jsxs)("div",{className:(0,a.A)("card__image",W.showcaseCardImage),children:[e.preview&&(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,style:{height:"150px",display:"flex"},children:(0,p.jsx)("img",{src:e.preview,style:{margin:"auto"},alt:" "})}),null==e.preview&&(0,p.jsx)("h2",{className:W.showcaseCardHeaderNoImage,children:e.title})]}),(0,p.jsxs)("div",{className:"card__body",children:[(0,p.jsxs)("div",{className:(0,a.A)(W.showcaseCardHeader),children:[(0,p.jsxs)(T.A,{as:"h4",className:W.showcaseCardTitle,children:[(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,children:e.title}),e.author&&(0,p.jsxs)("em",{style:{color:"grey"},children:[" by ",e.author]})]}),e.tags.includes("favorite")&&(0,p.jsx)(m,{svgClass:W.svgIconFavorite,size:"small"}),e.source&&(0,p.jsx)(d.A,{href:e.source,className:(0,a.A)("button button--secondary button--sm",W.showcaseCardSrcBtn),children:(0,p.jsx)("img",{src:"/img/github.svg",width:"20px"})})]}),(0,p.jsx)("p",{className:W.showcaseCardBody,children:e.description}),e.install&&(0,p.jsx)("div",{children:(0,p.jsxs)("details",{children:[(0,p.jsx)("summary",{children:(0,p.jsx)("em",{children:"Try it with..."})}),(0,p.jsx)(Y.A,{language:"yaml",children:e.install})]})})]}),(0,p.jsxs)("ul",{className:(0,a.A)("card__footer",W.cardFooter),children:[(0,p.jsxs)("div",{children:[e.downloads&&(0,p.jsx)("img",{className:"margin-right--sm",src:e.downloads}),e.last_commit&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last commit",src:e.last_commit}),e.last_release&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last release",src:e.last_release}),e.license&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub license",src:e.license})]}),(0,p.jsx)("div",{children:(0,p.jsx)(J,{tags:e.tags})})]})]},e.title)}const Q=s.memo(Z),X={filterCheckbox:"filterCheckbox_Feyr",checkboxList:"checkboxList_jTdS",checkboxListItem:"checkboxListItem_dFB0",searchContainer:"searchContainer_s3C6",showcaseList:"showcaseList_CRXj",showcaseFavorite:"showcaseFavorite_XwQD",showcaseFavoriteHeader:"showcaseFavoriteHeader_o0j3",svgIconFavoriteXs:"svgIconFavoriteXs_kiRS",svgIconFavorite:"svgIconFavorite_QxXa"},H=((0,r.T)({message:"dora-rs nodes hub"}),(0,r.T)({message:"List of Nodes already implemented by the community"})),K="https://discord.com/channels/1146393916472561734/1148336336294662196";function $(){if(i.A.canUseDOM)return{scrollTopPosition:window.scrollY,focusedElementId:document.activeElement?.id}}const tt="name";function et(t){return new URLSearchParams(t).get(tt)}function ot(t){const e=(0,n.zy)(),[o,a]=(0,s.useState)("OR"),[i,r]=(0,s.useState)([]),[l,d]=(0,s.useState)(null);return(0,s.useEffect)((()=>{r(R(e.search)),a(P(e.search)),d(et(e.search)),function(t){const{scrollTopPosition:e,focusedElementId:o}=t??{scrollTopPosition:0,focusedElementId:void 0};document.getElementById(o)?.focus(),window.scrollTo({top:e})}(e.state)}),[e]),(0,s.useMemo)((()=>function(t,e,o,s){return s&&(t=t.filter((t=>t.title.toLowerCase().includes(s.toLowerCase())))),0===e.length?t:t.filter((t=>0!==t.tags.length&&("AND"===o?e.every((e=>t.tags.includes(e))):e.some((e=>t.tags.includes(e))))))}(t,i,o,l)),[i,o,l])}function st(){return(0,p.jsxs)("section",{className:"margin-top--lg margin-bottom--lg text--center",children:[(0,p.jsx)("p",{children:H}),(0,p.jsx)(d.A,{className:"button button--primary",to:K,children:(0,p.jsx)(r.A,{id:"showcase.header.button",children:"\ud83d\ude4f Please add your Nodes"})})]})}function at(t){let{sortedExamples:e}=t;const o=ot(e),s=function(){const{selectMessage:t}=(0,l.W)();return e=>t(e,(0,r.T)({id:"showcase.filters.resultCount",description:'Pluralized label for the number of sites found on the showcase. Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',message:"1 site|{sitesCount} sites"},{sitesCount:e}))}();return(0,p.jsxs)("section",{className:"container margin-top--l margin-bottom--lg",children:[(0,p.jsxs)("div",{className:(0,a.A)("margin-bottom--sm",X.filterCheckbox),children:[(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.filters.title",children:"Filters"})}),(0,p.jsx)("span",{children:s(o.length)})]}),(0,p.jsx)(U,{})]}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.checkboxList),children:k.map(((t,e)=>{const{label:o,description:s,color:a}=j[t],i=`showcase_checkbox_id_${t}`;return(0,p.jsx)("li",{className:X.checkboxListItem,children:(0,p.jsx)(B,{id:i,text:s,anchorEl:"#__docusaurus",children:(0,p.jsx)(I,{tag:t,id:i,label:o,icon:"favorite"===t?(0,p.jsx)(m,{svgClass:X.svgIconFavoriteXs}):(0,p.jsx)("span",{style:{backgroundColor:a,width:10,height:10,borderRadius:"50%",marginLeft:8}})})})},e)}))})]})}function it(){const t=(0,n.W6)(),e=(0,n.zy)(),[o,a]=(0,s.useState)(null);return(0,s.useEffect)((()=>{a(et(e.search))}),[e]),(0,p.jsx)("div",{className:X.searchContainer,children:(0,p.jsx)("input",{id:"searchbar",placeholder:(0,r.T)({message:"Search for site name...",id:"showcase.searchBar.placeholder"}),value:o??void 0,onInput:o=>{a(o.currentTarget.value);const s=new URLSearchParams(e.search);s.delete(tt),o.currentTarget.value&&s.set(tt,o.currentTarget.value),t.push({...e,search:s.toString(),state:$()}),setTimeout((()=>{document.getElementById("searchbar")?.focus()}),0)}})})}function rt(t){let{sortedExamples:e,Categories:o}=t;const s=ot(e);return 0===s.length?(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container padding-vert--md text--center",children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.usersList.noResult",children:"No result"})}),(0,p.jsx)(it,{})]})}):(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container",children:[(0,p.jsx)("div",{className:(0,a.A)("margin-bottom--md",X.showcaseFavoriteHeader),children:(0,p.jsx)(it,{})}),(0,p.jsx)("div",{children:o.map((t=>{let e=s.filter((e=>e.category==t));return 0===e.length?null:(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:t}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.showcaseList),children:e.map((t=>(0,p.jsx)(Q,{user:t},t.title)))})]})}))})]})})}function nt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(st,{}),(0,p.jsx)(at,{sortedExamples:A}),(0,p.jsx)(rt,{sortedExamples:A,Categories:f})]})}function lt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(st,{}),(0,p.jsx)(at,{sortedExamples:N}),(0,p.jsx)(rt,{sortedExamples:N,Categories:_})]})}}}]); \ No newline at end of file +"use strict";(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[2394],{80756:(t,e,o)=>{o.r(e),o.d(e,{assets:()=>d,contentTitle:()=>n,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var s=o(74848),a=o(28453),i=o(96630);const r={sidebar_position:1},n="Search",l={id:"nodes/readme",title:"Search",description:"",source:"@site/docs/nodes/readme.mdx",sourceDirName:"nodes",slug:"/nodes/",permalink:"/docs/nodes/",draft:!1,unlisted:!1,editUrl:"https://github.com/dora-rs/dora-rs.github.io/edit/main/docs/nodes/readme.mdx",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1},sidebar:"nodes",next:{title:"Search",permalink:"/docs/nodes/"}},d={},c=[];function p(t){const e={h1:"h1",...(0,a.R)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.h1,{id:"search",children:"Search"}),"\n","\n",(0,s.jsx)(i.KE,{})]})}function h(t={}){const{wrapper:e}={...(0,a.R)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(p,{...t})}):p(t)}},96630:(t,e,o)=>{o.d(e,{KE:()=>rt,Ay:()=>nt,Ed:()=>K});var s=o(96540),a=o(20053),i=o(38193),r=o(21312),n=o(56347),l=o(53465),d=o(28774);const c={svgIcon:"svgIcon_R3jO",small:"small_SUAn",medium:"medium_GxVq",large:"large_TyPU",primary:"primary_V8Cc",secondary:"secondary_WyIo",success:"success_lY5U",error:"error_eHdq",warning:"warning_IB04",inherit:"inherit_2ln5"};var p=o(74848);function h(t){const{svgClass:e,colorAttr:o,children:s,color:i="inherit",size:r="medium",viewBox:n="0 0 24 24",...l}=t;return(0,p.jsx)("svg",{viewBox:n,color:o,"aria-hidden":!0,className:(0,a.A)(c.svgIcon,c[i],c[r],e),...l,children:s})}function m(t){return(0,p.jsx)(h,{...t,children:(0,p.jsx)("path",{d:"M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"})})}function u(t,e){const o=[...t];return o.sort(((t,o)=>e(t)>e(o)?1:e(o)>e(t)?-1:0)),o}const g=JSON.parse('[{"title":"Yolov5 Operator","description":"Yolov5 object detection operator","preview":"https://i.imgur.com/hPrazyl.jpg","website":"yolov5_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolov5_op.py","tags":["cv","python"]},{"title":"Plot Operator","description":"Plot operator based on cv2","preview":"https://i.imgur.com/ekEgDL5.png","website":"plot_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/plot.py","tags":["python"]},{"title":"PID Operator","description":"PID controller","preview":"https://i.imgur.com/AEmoZ7k.gif","website":"pid_control_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/pid_control_op.py","tags":["python","control"]},{"title":"Obstacle Location Operator","description":"Obstacle location based on LIDAR and 2D bounding boxes","preview":"https://i.imgur.com/Aq33qy5.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/obstacle_location_op.py","tags":["python"]},{"title":"FOT Operator","description":"Waypoint generation based on current position and frenet optimal trajectory planner.","preview":"https://i.imgur.com/klQitzg.png","website":"obstacle_location_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/fot_op.py","tags":["python"]},{"title":"YOLOP Operator","description":"YOLOP lane and drivable area detection","preview":"https://i.imgur.com/I531NIT.gif","website":"yolop_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/yolop_op.py","tags":["cv","python"]},{"title":"MiDaS Operator","description":"MiDaS depth estimation","preview":"https://i.imgur.com/UrF9iPN.png","website":"midas_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/midas_op.py","tags":["depth_estimation","python"]},{"title":"Webcam Operator","description":"Webcam Operator","preview":"https://i.imgur.com/CC0IW3i.png","website":"webcam_operator","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/webcam_op.py","tags":["python"]},{"title":"Strong Sort Operator","description":"Strong Sort Operator","preview":"https://i.imgur.com/ozO1y7l.gif","website":"strong_sort_op","source":"https://github.com/dora-rs/dora-drives/blob/main/operators/strong_sort_op.py","tags":["cv","python"]}]');var b=o.t(g,2);const y=JSON.parse('[{"title":"Speech to Text","description":"Transform speech to text.","preview":"/img/whisper.png.avif","website":"stt","source":"https://github.com/dora-rs/dora/blob/main/examples/speech-to-text","tags":["audio","python"],"category":"Audio","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fspeech-to-text"},{"title":"Translation","description":"Translate audio in real time.","website":"translation","source":"https://github.com/dora-rs/dora/blob/main/examples/translation","tags":["audio","python"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Ftranslation","category":"Audio"},{"title":"Vision Language Model","description":"Use a VLM to understand images.","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"vlm","source":"https://github.com/dora-rs/dora/blob/main/examples/vlm","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fvlm","tags":["python","image"],"category":"Vision"},{"title":"YOLO","description":"Use YOLO to detect object within image.","preview":"https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-banner.avif","website":"yolo","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":["python","image"],"category":"Vision"},{"title":"Camera","description":"Simple webcam plot example","preview":"https://upload.wikimedia.org/wikipedia/commons/3/35/AdventWebcam.jpg","website":"webcam","source":"https://github.com/dora-rs/dora/blob/main/examples/camera","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcamera","tags":["python","image"],"category":"Vision"},{"title":"Piper RDT","description":"Piper RDT Pipeline","website":"piper","source":"https://github.com/dora-rs/dora/blob/main/examples/piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpiper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","tags":["python","image"],"category":"Training"},{"title":"LeRobot - Alexander Koch","description":"Piper RDT Pipeline","website":"lerobot","source":"https://raw.githubusercontent.com/dora-rs/dora-lerobot/refs/heads/main/README.md","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-lerobot","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","tags":["python","image"],"category":"Training"},{"title":"C Example","description":"Example with C node","website":"c-example","preview":"https://iq.direct/images/C-programming.png","source":"https://github.com/dora-rs/dora/blob/main/examples/c-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ Example","description":"Example with C++ node","website":"c++-example","preview":"https://repository-images.githubusercontent.com/124365799/7d888300-6a39-11ea-9025-fd5574f062c7","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-dataflow","tags":[],"category":"Tutorial"},{"title":"CMake Example","description":"Example using CMake","website":"cmake-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ-IsFXHxaLnZWam5sEJvnUZAzGMyGzXfOKMmIX9XeugcL45yTIuizNbaYi4Y-obbI14A&usqp=CAU","source":"https://github.com/dora-rs/dora/blob/main/examples/cmake-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcmake-dataflow","tags":[],"category":"Tutorial"},{"title":"CUDA Example","description":"Example using CUDA Zero Copy","website":"cuda-example","preview":"https://d29g4g2dyqv443.cloudfront.net/sites/default/files/akamai/ros-dp-nitros.gif","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Tutorial"},{"title":"Rust Example","description":"Example using Rust","website":"rust-example","preview":"https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-light.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-dataflow","tags":[],"category":"Tutorial"},{"title":"Python Example","description":"Example using Python","website":"python-example","preview":"https://upload.wikimedia.org/wikipedia/commons/f/f8/Python_logo_and_wordmark.svg","source":"https://github.com/dora-rs/dora/blob/main/examples/python-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-dataflow","tags":[],"category":"Tutorial"},{"title":"Python ROS2 Example","description":"Example using Python ROS2","website":"python-ros2-example","preview":"https://www.aranacorp.com/wp-content/uploads/python-ros2.png","source":"https://github.com/dora-rs/dora/blob/main/examples/python-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fpython-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"Rust ROS2 Example","description":"Example using Rust ROS2","website":"rust-ros2-example","preview":"https://robonomics.network/assets/static/cover.d57b2e8.268586f3596831daf0d2d0fa2c885458.jpg","source":"https://github.com/dora-rs/dora/blob/main/examples/rust-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Frust-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"C++ ROS2 Example","description":"Example using C++ ROS2","website":"c++-ros2-example","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSnC1cXYAAjFUjNAogVCAr8HrAmumbx9nEnhg&s","source":"https://github.com/dora-rs/dora/blob/main/examples/c++-ros2-dataflow","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fc%2b%2b-ros2-dataflow","tags":[],"category":"Tutorial"},{"title":"CPU Benchmark","description":"CPU Benchmark of dora-rs","website":"cpu-benchmark","preview":"https://github.com/user-attachments/assets/3285d183-7560-40e1-ac02-30fee0f120cb","source":"https://github.com/dora-rs/dora-benchmark/blob/main","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora-benchmark","tags":[],"category":"Benchmark"},{"title":"GPU Benchmark","description":"GPU Benchmark of dora-rs","website":"gpu-benchmark","preview":"https://github.com/user-attachments/assets/d64370fc-b0ba-46af-be83-19d3c772ada6","source":"https://github.com/dora-rs/dora/blob/main/examples/cuda-benchmark","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=examples%2Fcuda-benchmark","tags":[],"category":"Benchmark"}]');var w=o.t(y,2);const v=JSON.parse('[{"title":"Whisper","description":"Transcribe audio to text","preview":"/img/whisper.png.avif","website":"whisper","github":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-distil-whisper","install":"- id: dora-distil-whisper\\n build: pip install dora-distil-whisper\\n path: dora-distil-whisper\\n inputs: \\n tick: /audio\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-distil-whisper","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-distil-whisper","last_release":"https://img.shields.io/pypi/v/dora-distil-whisper","license":"https://img.shields.io/pypi/l/dora-distil-whisper","category":"Speech to Text"},{"title":"Qwenvl","description":"Vision Language Model","preview":"https://github.com/QwenLM/Qwen-VL/raw/master/assets/logo.jpg","website":"qwenvl","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-qwenvl","install":"- id: dora-qwenvl\\n build: pip install dora-qwenvl\\n path: dora-qwenvl\\n inputs: \\n text: /text\\n image: /image\\n outputs: \\n - text","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-qwenvl","tags":["python","image","text"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-qwenvl","last_release":"https://img.shields.io/pypi/v/dora-qwenvl","license":"https://img.shields.io/pypi/l/dora-qwenvl","category":"Vision Language Model"},{"title":"Silero VAD","description":"Silero Voice activity detection","preview":"https://user-images.githubusercontent.com/12515440/89997349-b3523080-dc94-11ea-9906-ca2e8bc50535.png","website":"silero","author":"dora","downloads":"https://img.shields.io/pypi/dm/dora-vad","install":"- id: dora-vad\\n build: pip install dora-vad\\n path: dora-vad\\n inputs: \\n tick: /audio\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-vad","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-vad","last_release":"https://img.shields.io/pypi/v/dora-vad","license":"https://img.shields.io/pypi/l/dora-vad","category":"Voice Activity Detection"},{"title":"Microphone","description":"Audio from microphone","author":"dora","website":"microphone","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8EPOj0PAu4yyERZg4ncm-vMgBqaU5lSP6_Q&s","downloads":"https://img.shields.io/pypi/dm/dora-microphone","install":"- id: dora-microphone\\n build: pip install dora-microphone\\n path: dora-microphone\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - audio","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-microphone","tags":["python","audio"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-microphone","last_release":"https://img.shields.io/pypi/v/dora-microphone","license":"https://img.shields.io/pypi/l/dora-microphone","category":"Peripheral"},{"title":"Rerun","description":"Visualization tool","author":"dora","website":"rerun","downloads":"https://img.shields.io/pypi/dm/dora-rerun","install":"- id: dora-rerun\\n build: pip install dora-rerun\\n path: dora-rerun\\n inputs: \\n image: /image\\n text: /text","preview":"https://user-images.githubusercontent.com/1148717/218141237-0442d2b5-ed22-42bf-9321-10af1b894507.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rerun","tags":["rust","text","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rerun","last_release":"https://img.shields.io/pypi/v/dora-rerun","license":"https://img.shields.io/pypi/l/dora-rerun","category":"Visualization"},{"title":"Video Capture","description":"Image stream from Camera","author":"dora","website":"opencv-video-capture","install":"- id: opencv-video-capture\\n build: pip install opencv-video-capture\\n path: opencv-video-capture\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image","downloads":"https://img.shields.io/pypi/dm/opencv-video-capture","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-video-capture","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-video-capture","last_release":"https://img.shields.io/pypi/v/opencv-video-capture","license":"https://img.shields.io/pypi/l/opencv-video-capture","tags":["python","image"],"category":"Camera"},{"title":"Yolov8","description":"Object detection","author":"dora","website":"yolo","install":"- id: dora-yolo\\n build: pip install dora-yolo\\n path: dora-yolo\\n inputs: \\n image: /image\\n outputs: \\n - bbox","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-yolo","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-yolo","last_release":"https://img.shields.io/pypi/v/dora-yolo","license":"https://img.shields.io/pypi/l/dora-yolo","tags":["python","image"],"category":"Object Detection"},{"title":"Plot","description":"Simple OpenCV plot visualization","author":"dora","website":"opencv-plot","install":"- id: opencv-plot\\n build: pip install opencv-plot\\n path: opencv-plot\\n inputs: \\n image: /image\\n text: /text","downloads":"https://img.shields.io/pypi/dm/dora-yolo","preview":"https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_no_text-1.svg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/opencv-plot","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fopencv-plot","last_release":"https://img.shields.io/pypi/v/opencv-plot","license":"https://img.shields.io/pypi/l/opencv-plot","tags":["python","image","text"],"category":"Visualization"},{"title":"PyRealsense","description":"Image and depth from Realsense","author":"dora","website":"pyrealsense","install":"- id: dora-pyrealsense\\n build: pip install dora-pyrealsense\\n path: dora-pyrealsense\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth","downloads":"https://img.shields.io/pypi/dm/dora-pyrealsense","preview":"https://user-images.githubusercontent.com/41145062/193884336-c30397be-2cac-45da-ba34-07e7db9843e8.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyrealsense","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyrealsense","last_release":"https://img.shields.io/pypi/v/dora-pyrealsense","license":"https://img.shields.io/pypi/l/dora-pyrealsense","tags":["python","image","depth"],"category":"Camera"},{"title":"PyOrbbeckSDK","description":"Image and depth from Orbbeck Camera","author":"dora","website":"pyorbbecsdk","install":"- id: dora-pyorbbecksdk\\n build: pip install dora-pyorbbecksdk\\n path: dora-pyorbbecksdk\\n inputs: \\n tick: dora/timer/millis/50\\n outputs: \\n - image\\n - depth\\n - image_depth","downloads":"https://img.shields.io/pypi/dm/dora-pyorbbecksdk","preview":"https://new-orbbec3d-s3.s3.amazonaws.com/wp-content/uploads/2024/06/03120334/\u53f345\u5ea6-e1717416268437-300x153.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-pyorbbecksdk","tags":["python","image","depth"],"last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-pyorbbecksdk","last_release":"https://img.shields.io/pypi/v/dora-pyorbbecksdk","license":"https://img.shields.io/pypi/l/dora-pyorbbecksdk","category":"Camera"},{"title":"Keyboard","description":"Keyboard char listener","author":"dora","website":"keyboard","install":"- id: dora-keyboard\\n build: pip install dora-keyboard\\n path: dora-keyboard\\n inputs: \\n tick: dora/timer/millis/1000\\n outputs: \\n - char","downloads":"https://img.shields.io/pypi/dm/dora-keyboard","preview":"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/LenovoKeyboard.jpg/220px-LenovoKeyboard.jpg","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-keyboard","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-keyboard","last_release":"https://img.shields.io/pypi/v/dora-keyboard","license":"https://img.shields.io/pypi/l/dora-keyboard","tags":["python","text"],"category":"Peripheral"},{"title":"Agilex - Piper","description":"Agilex arm client","author":"dora","website":"piper","install":"- id: dora-piper\\n build: pip install dora-piper\\n path: dora-piper\\n inputs: \\n tick: dora/timer/millis/20\\n joint_action: /jointstate\\n outputs: \\n - jointstate","downloads":"https://img.shields.io/pypi/dm/dora-piper","preview":"https://global.agilex.ai/cdn/shop/files/PIPER0814.00_00_37_00.Still004.jpg?v=1724743157&width=3840","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-piper","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-piper","last_release":"https://img.shields.io/pypi/v/dora-piper","license":"https://img.shields.io/pypi/l/dora-piper","tags":["python"],"category":"Arm"},{"title":"Opus MT","description":"Translate text between language","author":"dora","website":"opus","install":"- id: dora-opus\\n build: pip install dora-opus\\n path: dora-opus\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","downloads":"https://img.shields.io/pypi/dm/dora-opus","preview":"https://github.com/Helsinki-NLP/Opus-MT/raw/master/img/opus_mt.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-opus","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-opus","last_release":"https://img.shields.io/pypi/v/dora-opus","license":"https://img.shields.io/pypi/l/dora-opus","tags":["python","text"],"category":"Translation"},{"title":"Llama Factory Recorder","description":"Record data to train LLM and VLM","author":"dora","website":"llama-factory-recorder","install":"- id: llama-factory-recorder\\n build: pip install llama-factory-recorder\\n path: llama-factory-recorder\\n inputs: \\n image: /image\\n text: /text\\n ground_truth: /text\\n outputs: \\n - text","downloads":"https://img.shields.io/pypi/dm/llama-factory-recorder","preview":"https://github.com/hiyouga/LLaMA-Factory/blob/main/assets/logo.png?raw=true","source":"https://github.com/dora-rs/dora/blob/main/node-hub/llama-factory-recorder","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fllama-factory-recorder","last_release":"https://img.shields.io/pypi/v/llama-factory-recorder","license":"https://img.shields.io/pypi/l/llama-factory-recorder","tags":["python","image","text"],"category":"Recorder"},{"title":"RDT-1B","description":"Infer policy using Robotic Diffusion Transformer","author":"dora","website":"rdt","install":"- id: dora-rdt-1b\\n build: pip install dora-rdt-1b\\n path: dora-rdt-1b\\n inputs: \\n image: /image\\n jointstate: /jointstate\\n outputs: \\n - action","downloads":"https://img.shields.io/pypi/dm/dora-rdt-1b","preview":"https://github.com/thu-ml/RoboticsDiffusionTransformer/raw/main/assets/head.png","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-rdt-1b","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-rdt-1b","last_release":"https://img.shields.io/pypi/v/dora-rdt-1b","license":"https://img.shields.io/pypi/l/dora-rdt-1b","tags":["python","image","text"],"category":"Vision Language Action"},{"title":"Dynamixel","description":"Dynamixel Client","author":"Enzo Levan","website":"dynamixel","preview":"https://robots.ros.org/assets/img/robots/dynamixel/dynamixel.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dynamixel-client","tags":["python"],"category":"Actuator"},{"title":"Feetech","description":"Feetech Client","author":"Enzo Levan","website":"feetech","preview":"https://media.licdn.com/dms/image/v2/C5612AQGpeiwwIPDqaw/article-cover_image-shrink_720_1280/article-cover_image-shrink_720_1280/0/1647414552058?e=2147483647&v=beta&t=QoHYcvm7pla6ptYtg3daKPAGRRctKGEkIGkBrGyE25Y","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/feetech-client","tags":["python"],"category":"Actuator"},{"title":"Mujoco","description":"Mujoco Simulator","author":"Enzo Levan","website":"mujoco","preview":"https://github.com/google-deepmind/mujoco/raw/main/banner.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/mujoco-client","tags":["python"],"category":"Simulator"},{"title":"Lebai - LM3","description":"Lebai client","author":"dora","website":"lebai","preview":"https://l-www.lebai.ltd/2015/07/1-495x400.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lebai-client","tags":["python"],"category":"Arm"},{"title":"Alex Koch - Low Cost Robot","description":"Alex Koch - Low Cost Robot Client","author":"dora","website":"alex-koch-low-cost-robot","preview":"https://github.com/AlexanderKoch-Koch/low_cost_robot/raw/main/pictures/robot_portait.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/alexk-lcr","tags":["python"],"category":"Arm"},{"title":"Trossen - Aloha","description":"Aloha client","author":"dora","website":"aloha","preview":"https://static.wixstatic.com/media/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg/v1/fill/w_1000,h_659,al_c,q_85,usm_0.66_1.00_0.01/d3716d_7d9108b35b194e3c806cc260fcfd7268~mv2.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/aloha","tags":["python"],"category":"Robot"},{"title":"Pollen - Reachy 2","description":"Reachy 2 client","author":"dora","website":"reachy2","preview":"https://www.lejournaldesentreprises.com/sites/lejournaldesentreprises.com/files/styles/landscape_web_lg_1x/public/2024-11/Reachy-2-sait-reprer-un-objet-le-saisir-et-le-m-15512511.jpeg?itok=syrnHhWx","source":"https://github.com/dora-rs/dora-lerobot/blob/main/robots/reachy","tags":["python"],"category":"Robot"},{"title":"Carla","description":"Carla Simulator","author":"dora","website":"carla","preview":"https://media.licdn.com/dms/image/v2/D4D1BAQHyb4EFail-wQ/company-background_10000/company-background_10000/0/1663774857825/carla_simulator_cover?e=2147483647&v=beta&t=AmftWPQMtfni1t_RXUvqqkQJqxKK_I54BoHpLLSwjWE","source":"https://github.com/dora-rs/dora-drives","tags":["python"],"category":"Simulator"},{"title":"Pollen - Reachy 1","description":"Reachy 1 Client","author":"dora","website":"reachy1","install":"- id: dora-reachy1\\n build: pip install dora-reachy1\\n path: dora-reachy1","preview":"https://www.aquitaineonline.com/images/stories/Economie_Industrie_2021/Reachy_01.jpg","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/dora-reachy1","tags":["python"],"category":"Robot"},{"title":"DJI - Robomaster S1","description":"Robomaster Client","author":"dora","website":"robomaster-s1","preview":"https://m.media-amazon.com/images/I/61K2UXjfHwL.jpg","source":"https://huggingface.co/datasets/dora-rs/dora-robomaster","tags":["python"],"category":"Chassis"},{"title":"Agilex - UGV","description":"Robomaster Client","author":"dora","website":"robomaster-s1","downloads":"https://img.shields.io/pypi/dm/dora-ugv","preview":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvTwJ589Zudgva9TIQ79ddJ8wHUq2_jmrUZg&s","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-ugv","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-ugv","last_release":"https://img.shields.io/pypi/v/dora-ugv","license":"https://img.shields.io/pypi/l/dora-ugv","tags":["python"],"category":"Chassis"},{"title":"Dora Kit Car","description":"Open Source Chassis","author":"dora","website":"dora-kit-car","downloads":"https://img.shields.io/pypi/dm/dora-kit-car","preview":"https://github.com/RuPingCen/mick_robot_chassis/raw/master/README.assets/fengmian.gif","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-kit-car","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-kit-car","last_release":"https://img.shields.io/pypi/v/dora-kit-car","license":"https://img.shields.io/pypi/l/dora-kit-car","tags":["python"],"category":"Chassis"},{"title":"ArgosTranslate","description":"Open Source translation engine","author":"dora","website":"argotranslate","downloads":"https://img.shields.io/pypi/dm/dora-argotranslate","install":"- id: dora-argotranslate\\n build: pip install dora-argotranslate\\n path: dora-argotranslate\\n inputs: \\n text: /text\\n outputs: \\n - text\\n env:\\n SOURCE_LANGUAGE: en\\n TARGET_LANGUAGE: fr","preview":"https://avatars.githubusercontent.com/u/48267258?v=4","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-argotranslate","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-argotranslate","last_release":"https://img.shields.io/pypi/v/dora-argotranslate","license":"https://img.shields.io/pypi/l/dora-argotranslate","tags":["python"],"category":"Translation"},{"title":"InternVL","description":"InternVL is a vision language model","author":"dora","website":"internvl","downloads":"https://img.shields.io/pypi/dm/dora-internvl","preview":"https://private-user-images.githubusercontent.com/23737120/379689418-930e6814-8a9f-43e1-a284-118a5732daa4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYzNDcwODEsIm5iZiI6MTczNjM0Njc4MSwicGF0aCI6Ii8yMzczNzEyMC8zNzk2ODk0MTgtOTMwZTY4MTQtOGE5Zi00M2UxLWEyODQtMTE4YTU3MzJkYWE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA4VDE0MzMwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3YTUyM2UyMDc5ZmMxNjk5NWZmNzg4ZjgxN2VkNzIyOTFmYjc2OGJiZGJlOWQ1Y2Q4NWU2OTJhYmRjMzZhZjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uiWkdjPEgeUJkiCVNii9Huh4M1ykJ2Cm_FVcTDcldYs","source":"https://github.com/dora-rs/dora/blob/main/node-hub/dora-internvl","last_commit":"https://img.shields.io/github/last-commit/dora-rs/dora?path=node-hub%2Fdora-internvl","last_release":"https://img.shields.io/pypi/v/dora-internvl","license":"https://img.shields.io/pypi/l/dora-internvl","tags":["python"],"category":"Vision Language Model"},{"title":"LeRobot Recorder","description":"LeRobot Recorder helper","author":"dora","website":"lerobot-dashboard","preview":"https://cdn-uploads.huggingface.co/production/uploads/631ce4b244503b72277fc89f/MNkMdnJqyPvOAEg20Mafg.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/node-hub/lerobot-dashboard","tags":["python"],"category":"Recorder"},{"title":"Gymnasium","description":"Experimental OpenAI Gymnasium bridge","author":"dora","website":"gymnasium","preview":"https://raw.githubusercontent.com/Farama-Foundation/Gymnasium/main/gymnasium-text.png","source":"https://github.com/dora-rs/dora-lerobot/blob/main/gym_dora","tags":["python"],"category":"Simulator"}]');var x=o.t(v,2);const f=["Camera","Peripheral","Actuator","Chassis","Arm","Robot","Voice Activity Detection","Speech to Text","Object Detection","Vision Language Model","Large Language Model","Vision Language Action","Translation","Text to Speech","Recorder","Visualization","Simulator"],_=["Audio","Vision","Training","Tutorial","Benchmark"],j={image:{label:(0,r.T)({id:"showcase.tag.image.tag",message:"image"}),description:(0,r.T)({message:"Computer vision related nodes!",id:"showcase.tag.image.description"}),color:"#39ca30"},python:{label:(0,r.T)({id:"showcase.tag.python.tag",message:"python"}),description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.python.description"}),color:"#dfd545"},rust:{label:"rust",description:(0,r.T)({message:"Docusaurus sites associated to a commercial product!",id:"showcase.tag.rust.description"}),color:"#333e2e"},control:{label:(0,r.T)({id:"showcase.tag.control.tag",message:"control"}),description:(0,r.T)({message:"Beautiful Docusaurus sites, polished and standing out from the initial template!",id:"showcase.tag.control.description"}),color:"#a44fb7"},depth:{label:(0,r.T)({id:"showcase.tag.depth.tag",message:"depth"}),description:(0,r.T)({message:"Translated Docusaurus sites using the internationalization support with more than 1 locale.",id:"showcase.tag.depth.description"}),color:"#127f82"},audio:{label:(0,r.T)({message:"audio"}),description:(0,r.T)({message:"Docusaurus sites using the versioning feature of the docs plugin to manage multiple versions.",id:"showcase.tag.audio.description"}),color:"#fe6829"},text:{label:(0,r.T)({message:"text"}),description:(0,r.T)({message:"Very large Docusaurus sites, including many more pages than the average!",id:"showcase.tag.large.description"}),color:"#8c2f00"}},k=Object.keys(j),C=b,E=w,L=x;!function(){let t=C.default;t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite")))}();const N=function(){let t=E.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();const A=function(){let t=L.default;return t=u(t,(t=>t.title.toLowerCase())),t=u(t,(t=>!t.tags.includes("favorite"))),t}();var T=o(51107);const O="checkboxLabel_0lFL",F="tags";function R(t){return new URLSearchParams(t).getAll(F)}function S(t,e){let{id:o,icon:a,label:i,tag:r,...l}=t;const d=(0,n.zy)(),c=(0,n.W6)(),[h,m]=(0,s.useState)(!1);(0,s.useEffect)((()=>{const t=R(d.search);m(t.includes(r))}),[r,d]);const u=(0,s.useCallback)((()=>{const t=function(t,e){const o=t.indexOf(e);if(-1===o)return t.concat(e);const s=[...t];return s.splice(o,1),s}(R(d.search),r),e=function(t,e){const o=new URLSearchParams(t);return o.delete(F),e.forEach((t=>o.append(F,t))),o.toString()}(d.search,t);c.push({...d,search:e,state:K()})}),[r,d,c]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("input",{type:"checkbox",id:o,className:"screen-reader-only",onKeyDown:t=>{"Enter"===t.key&&u()},onFocus:t=>{t.relatedTarget&&t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("focus"))},onBlur:t=>{t.target.nextElementSibling?.dispatchEvent(new KeyboardEvent("blur"))},onChange:u,checked:h,...l}),(0,p.jsxs)("label",{ref:e,htmlFor:o,className:O,children:[i,a]})]})}const I=s.forwardRef(S),D={checkboxLabel:"checkboxLabel_tOkT"},M="operator";function P(t){return new URLSearchParams(t).get(M)??"OR"}function U(){const t="showcase_filter_toggle",e=(0,n.zy)(),o=(0,n.W6)(),[i,r]=(0,s.useState)(!1);(0,s.useEffect)((()=>{r("AND"===P(e.search))}),[e]);const l=(0,s.useCallback)((()=>{r((t=>!t));const t=new URLSearchParams(e.search);t.delete(M),i||t.append(M,"AND"),o.push({...e,search:t.toString(),state:K()})}),[i,e,o]);return(0,p.jsxs)("div",{children:[(0,p.jsx)("input",{type:"checkbox",id:t,className:"screen-reader-only","aria-label":"Toggle between or and and for the tags you selected",onChange:l,onKeyDown:t=>{"Enter"===t.key&&l()},checked:i}),(0,p.jsxs)("label",{htmlFor:t,className:(0,a.A)(D.checkboxLabel,"shadow--md"),children:[(0,p.jsx)("span",{className:D.checkboxLabelOr,children:"OR"}),(0,p.jsx)("span",{className:D.checkboxLabelAnd,children:"AND"})]})]})}var V=o(40961),z=o(50991);const G={tooltip:"tooltip_vy6_",tooltipArrow:"tooltipArrow_lQYZ"};function B(t){let{children:e,id:o,anchorEl:a,text:i}=t;const[r,n]=(0,s.useState)(!1),[l,d]=(0,s.useState)(null),[c,h]=(0,s.useState)(null),[m,u]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),{styles:y,attributes:w}=(0,z.E)(l,c,{modifiers:[{name:"arrow",options:{element:m}},{name:"offset",options:{offset:[0,8]}}]}),v=(0,s.useRef)(null),x=`${o}_tooltip`;return(0,s.useEffect)((()=>{b(a?"string"==typeof a?document.querySelector(a):a:document.body)}),[g,a]),(0,s.useEffect)((()=>{const t=["mouseenter","focus"],e=["mouseleave","blur"],o=()=>{""!==i&&(l?.removeAttribute("title"),v.current=window.setTimeout((()=>{n(!0)}),400))},s=()=>{clearInterval(v.current),n(!1)};return l&&(t.forEach((t=>{l.addEventListener(t,o)})),e.forEach((t=>{l.addEventListener(t,s)}))),()=>{l&&(t.forEach((t=>{l.removeEventListener(t,o)})),e.forEach((t=>{l.removeEventListener(t,s)})))}}),[l,i]),(0,p.jsxs)(p.Fragment,{children:[s.cloneElement(e,{ref:d,"aria-describedby":r?x:void 0}),g?V.createPortal(r&&(0,p.jsxs)("div",{id:x,role:"tooltip",ref:h,className:G.tooltip,style:y.popper,...w.popper,children:[i,(0,p.jsx)("span",{ref:u,className:G.tooltipArrow,style:y.arrow})]}),g):g]})}const W={showcaseCardImage:"showcaseCardImage_RonU",showcaseCardHeader:"showcaseCardHeader_DBrh",showcaseCardHeaderNoImage:"showcaseCardHeaderNoImage_I3oL",showcaseCardTitle:"showcaseCardTitle_c4K_",svgIconFavorite:"svgIconFavorite_eNhx",showcaseCardSrcBtn:"showcaseCardSrcBtn_zC6u",showcaseCardBody:"showcaseCardBody_Uq33",cardFooter:"cardFooter_jnMp",tag:"tag_rgoW",textLabel:"textLabel_Um7W",colorLabel:"colorLabel_wSaw"};var Y=o(21432);const q=s.forwardRef(((t,e)=>{let{label:o,color:s,description:a}=t;return(0,p.jsxs)("li",{ref:e,className:W.tag,title:a,children:[(0,p.jsx)("span",{className:W.textLabel,children:o.toLowerCase()}),(0,p.jsx)("span",{className:W.colorLabel,style:{backgroundColor:s}})]})}));function J(t){let{tags:e}=t;const o=u(e.map((t=>({tag:t,...j[t]}))),(t=>k.indexOf(t.tag)));return(0,p.jsx)(p.Fragment,{children:o.map(((t,e)=>{const o=`showcase_card_tag_${t.tag}`;return(0,p.jsx)(B,{text:t.description,anchorEl:"#__docusaurus",id:o,children:(0,p.jsx)(q,{...t},e)},e)}))})}function Z(t){let{user:e}=t;!function(t){t.preview}(e);const o=e.source;return(0,p.jsxs)("li",{className:"card shadow--md",children:[(0,p.jsxs)("div",{className:(0,a.A)("card__image",W.showcaseCardImage),children:[e.preview&&(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,style:{height:"150px",display:"flex"},children:(0,p.jsx)("img",{src:e.preview,style:{margin:"auto"},alt:" "})}),null==e.preview&&(0,p.jsx)("h2",{className:W.showcaseCardHeaderNoImage,children:e.title})]}),(0,p.jsxs)("div",{className:"card__body",children:[(0,p.jsxs)("div",{className:(0,a.A)(W.showcaseCardHeader),children:[(0,p.jsxs)(T.A,{as:"h4",className:W.showcaseCardTitle,children:[(0,p.jsx)(d.A,{href:o,className:W.showcaseCardLink,children:e.title}),e.author&&(0,p.jsxs)("em",{style:{color:"grey"},children:[" by ",e.author]})]}),e.tags.includes("favorite")&&(0,p.jsx)(m,{svgClass:W.svgIconFavorite,size:"small"}),e.source&&(0,p.jsx)(d.A,{href:e.source,className:(0,a.A)("button button--secondary button--sm",W.showcaseCardSrcBtn),children:(0,p.jsx)("img",{src:"/img/github.svg",width:"20px"})})]}),(0,p.jsx)("p",{className:W.showcaseCardBody,children:e.description}),e.install&&(0,p.jsx)("div",{children:(0,p.jsxs)("details",{children:[(0,p.jsx)("summary",{children:(0,p.jsx)("em",{children:"Try it with..."})}),(0,p.jsx)(Y.A,{language:"yaml",children:e.install})]})})]}),(0,p.jsxs)("ul",{className:(0,a.A)("card__footer",W.cardFooter),children:[(0,p.jsxs)("div",{children:[e.downloads&&(0,p.jsx)("img",{className:"margin-right--sm",src:e.downloads}),e.last_commit&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last commit",src:e.last_commit}),e.last_release&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub last release",src:e.last_release}),e.license&&(0,p.jsx)("img",{className:"margin-right--sm",alt:"GitHub license",src:e.license})]}),(0,p.jsx)("div",{children:(0,p.jsx)(J,{tags:e.tags})})]})]},e.title)}const Q=s.memo(Z),X={filterCheckbox:"filterCheckbox_Feyr",checkboxList:"checkboxList_jTdS",checkboxListItem:"checkboxListItem_dFB0",searchContainer:"searchContainer_s3C6",showcaseList:"showcaseList_CRXj",showcaseFavorite:"showcaseFavorite_XwQD",showcaseFavoriteHeader:"showcaseFavoriteHeader_o0j3",svgIconFavoriteXs:"svgIconFavoriteXs_kiRS",svgIconFavorite:"svgIconFavorite_QxXa"},H="https://github.com/dora-rs/dora-rs.github.io/blob/main/src/data/nodes.json";function K(){if(i.A.canUseDOM)return{scrollTopPosition:window.scrollY,focusedElementId:document.activeElement?.id}}const $="name";function tt(t){return new URLSearchParams(t).get($)}function et(t){const e=(0,n.zy)(),[o,a]=(0,s.useState)("OR"),[i,r]=(0,s.useState)([]),[l,d]=(0,s.useState)(null);return(0,s.useEffect)((()=>{r(R(e.search)),a(P(e.search)),d(tt(e.search)),function(t){const{scrollTopPosition:e,focusedElementId:o}=t??{scrollTopPosition:0,focusedElementId:void 0};document.getElementById(o)?.focus(),window.scrollTo({top:e})}(e.state)}),[e]),(0,s.useMemo)((()=>function(t,e,o,s){return s&&(t=t.filter((t=>t.title.toLowerCase().includes(s.toLowerCase())))),0===e.length?t:t.filter((t=>0!==t.tags.length&&("AND"===o?e.every((e=>t.tags.includes(e))):e.some((e=>t.tags.includes(e))))))}(t,i,o,l)),[i,o,l])}function ot(t){let{text:e,url:o}=t;return(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--lg text--center",children:(0,p.jsx)(d.A,{className:"button button--primary",to:o,children:e})})}function st(t){let{sortedExamples:e}=t;const o=et(e),s=function(){const{selectMessage:t}=(0,l.W)();return e=>t(e,(0,r.T)({id:"showcase.filters.resultCount",description:'Pluralized label for the number of sites found on the showcase. Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',message:"1 site|{sitesCount} sites"},{sitesCount:e}))}();return(0,p.jsxs)("section",{className:"container margin-top--l margin-bottom--lg",children:[(0,p.jsxs)("div",{className:(0,a.A)("margin-bottom--sm",X.filterCheckbox),children:[(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.filters.title",children:"Filters"})}),(0,p.jsx)("span",{children:s(o.length)})]}),(0,p.jsx)(U,{})]}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.checkboxList),children:k.map(((t,e)=>{const{label:o,description:s,color:a}=j[t],i=`showcase_checkbox_id_${t}`;return(0,p.jsx)("li",{className:X.checkboxListItem,children:(0,p.jsx)(B,{id:i,text:s,anchorEl:"#__docusaurus",children:(0,p.jsx)(I,{tag:t,id:i,label:o,icon:"favorite"===t?(0,p.jsx)(m,{svgClass:X.svgIconFavoriteXs}):(0,p.jsx)("span",{style:{backgroundColor:a,width:10,height:10,borderRadius:"50%",marginLeft:8}})})})},e)}))})]})}function at(){const t=(0,n.W6)(),e=(0,n.zy)(),[o,a]=(0,s.useState)(null);return(0,s.useEffect)((()=>{a(tt(e.search))}),[e]),(0,p.jsx)("div",{className:X.searchContainer,children:(0,p.jsx)("input",{id:"searchbar",placeholder:(0,r.T)({message:"Search for site name...",id:"showcase.searchBar.placeholder"}),value:o??void 0,onInput:o=>{a(o.currentTarget.value);const s=new URLSearchParams(e.search);s.delete($),o.currentTarget.value&&s.set($,o.currentTarget.value),t.push({...e,search:s.toString(),state:K()}),setTimeout((()=>{document.getElementById("searchbar")?.focus()}),0)}})})}function it(t){let{sortedExamples:e,Categories:o}=t;const s=et(e);return 0===s.length?(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container padding-vert--md text--center",children:[(0,p.jsx)(T.A,{as:"h2",children:(0,p.jsx)(r.A,{id:"showcase.usersList.noResult",children:"No result"})}),(0,p.jsx)(at,{})]})}):(0,p.jsx)("section",{className:"margin-top--lg margin-bottom--xl",children:(0,p.jsxs)("div",{className:"container",children:[(0,p.jsx)("div",{className:(0,a.A)("margin-bottom--md",X.showcaseFavoriteHeader),children:(0,p.jsx)(at,{})}),(0,p.jsx)("div",{children:o.map((t=>{let e=s.filter((e=>e.category==t));return 0===e.length?null:(0,p.jsxs)("div",{children:[(0,p.jsx)(T.A,{as:"h2",children:t}),(0,p.jsx)("ul",{className:(0,a.A)("clean-list",X.showcaseList),children:e.map((t=>(0,p.jsx)(Q,{user:t},t.title)))})]})}))})]})})}function rt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(ot,{url:H,text:"Showcase your nodes \ud83d\udd25"}),(0,p.jsx)(st,{sortedExamples:A}),(0,p.jsx)(it,{sortedExamples:A,Categories:f})]})}function nt(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(ot,{url:H,text:"Showcase your examples \ud83d\udd25"}),(0,p.jsx)(st,{sortedExamples:N}),(0,p.jsx)(it,{sortedExamples:N,Categories:_})]})}}}]); \ No newline at end of file diff --git a/assets/js/main.7e1fbb86.js b/assets/js/main.e0c5ef23.js similarity index 98% rename from assets/js/main.7e1fbb86.js rename to assets/js/main.e0c5ef23.js index 3a5d7ac2..df94a5d3 100644 --- a/assets/js/main.7e1fbb86.js +++ b/assets/js/main.e0c5ef23.js @@ -1,2 +1,2 @@ -/*! For license information please see main.7e1fbb86.js.LICENSE.txt */ -(self.webpackChunkdora_rs_github_io=self.webpackChunkdora_rs_github_io||[]).push([[8792],{89188:(e,t,n)=>{"use strict";n.d(t,{W:()=>a});var r=n(96540);function a(){return r.createElement("svg",{width:"20",height:"20",className:"DocSearch-Search-Icon",viewBox:"0 0 20 20","aria-hidden":"true"},r.createElement("path",{d:"M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z",stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"}))}},35947:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});n(96540);var r=n(53259),a=n.n(r),o=n(84054);const i={"02818252":[()=>n.e(8303).then(n.bind(n,62070)),"@site/docs/guides/dora-drives/obstacle_location.mdx",62070],"0d4da485":[()=>n.e(4945).then(n.bind(n,81445)),"@site/docs/references/communication-layer.md",81445],"111d35bc":[()=>n.e(523).then(n.bind(n,69946)),"@site/docs/guides/dora-drives/control.mdx",69946],"11b008f6":[()=>n.e(4815).then(n.bind(n,23142)),"@site/docs/guides/getting-started/conversation_py.md",23142],"12d79d84":[()=>n.e(1922).then(n.bind(n,30975)),"@site/docs/nodes_operators/plot.md",30975],"164dcfa3":[()=>n.e(4909).then(n.bind(n,22800)),"@site/docs/guides/getting-started/webcam_plot.md",22800],17896441:[()=>Promise.all([n.e(1869),n.e(5394),n.e(9911),n.e(8401)]).then(n.bind(n,12447)),"@theme/DocItem",12447],"19edae22":[()=>Promise.all([n.e(1869),n.e(5692)]).then(n.bind(n,53773)),"@site/docs/references/readme.mdx",53773],"1a4e3797":[()=>Promise.all([n.e(1869),n.e(2138)]).then(n.bind(n,10673)),"@theme/SearchPage",10673],"1c4ae0dc":[()=>n.e(8902).then(n.bind(n,3321)),"@site/blog/rust-python.md",3321],"1cd62bc7":[()=>Promise.all([n.e(1869),n.e(5394),n.e(4939),n.e(4643)]).then(n.bind(n,57832)),"@site/docs/examples/readme.mdx",57832],"1f391b9e":[()=>Promise.all([n.e(1869),n.e(5394),n.e(9911),n.e(6061)]).then(n.bind(n,67973)),"@theme/MDXPage",67973],"20b4f8b6":[()=>n.e(521).then(n.t.bind(n,61966,19)),"/home/runner/work/dora-rs.github.io/dora-rs.github.io/.docusaurus/docusaurus-plugin-content-docs/default/plugin-route-context-module-100.json",61966],"24273ae4":[()=>n.e(959).then(n.bind(n,80543)),"@site/docs/guides/Debugging/tracing.md",80543],"26a8c297":[()=>n.e(1239).then(n.bind(n,66235)),"@site/docs/api/cli.md",66235],"290ed830":[()=>n.e(7268).then(n.bind(n,44369)),"@site/docs/guides/dora-ros2-bridges/dora-ros2-bridges.md",44369],"32b584a3":[()=>n.e(5159).then(n.bind(n,81819)),"@site/blog/rust-python.md?truncated=true",81819],34444017:[()=>n.e(6562).then(n.bind(n,60514)),"@site/docs/guides/getting-started/llm.md",60514],"3c22fb1c":[()=>n.e(8073).then(n.bind(n,33509)),"@site/docs/guides/dora-drives/installation.mdx",33509],"41a76f56":[()=>n.e(5739).then(n.bind(n,16226)),"@site/docs/references/state-management.md",16226],"4a88671f":[()=>n.e(3178).then(n.bind(n,29082)),"@site/docs/guides/Debugging/logs.md",29082],"510fc99a":[()=>n.e(1657).then(n.bind(n,31657)),"@site/docs/guides/Development/Cuda.md",31657],"52655b79":[()=>Promise.all([n.e(1869),n.e(5394),n.e(6880)]).then(n.bind(n,9658)),"@site/docs/guides/Installation/installing.mdx",9658],"5641196c":[()=>n.e(8732).then(n.bind(n,85217)),"@site/docs/nodes_operators/obstacle_location_op.md",85217],"5b1a18fd":[()=>n.e(8381).then(n.t.bind(n,52945,19)),"/home/runner/work/dora-rs.github.io/dora-rs.github.io/.docusaurus/docusaurus-plugin-content-blog/default/plugin-route-context-module-100.json",52945],"5e95c892":[()=>n.e(9647).then(n.bind(n,7121)),"@theme/DocsRoot",7121],"5e9f5e1a":[()=>Promise.resolve().then(n.bind(n,4784)),"@generated/docusaurus.config",4784],"60226b7e":[()=>n.e(9829).then(n.bind(n,26310)),"@site/docs/guides/getting-started/yolov8.md",26310],"60c29953":[()=>n.e(4416).then(n.bind(n,67543)),"@site/docs/nodes_operators/yolop_op.md",67543],"60c315c7":[()=>n.e(4955).then(n.t.bind(n,57757,19)),"/home/runner/work/dora-rs.github.io/dora-rs.github.io/.docusaurus/docusaurus-theme-search-algolia/default/plugin-route-context-module-100.json",57757],"613499f9":[()=>n.e(1164).then(n.bind(n,30972)),"@site/docs/nodes_operators/yolov5_op.md",30972],"6334eb60":[()=>n.e(4796).then(n.bind(n,8124)),"@site/docs/nodes_operators/midas_op.md",8124],68763961:[()=>Promise.all([n.e(1869),n.e(5394),n.e(4589)]).then(n.bind(n,91608)),"@site/src/pages/installation-scripts.mdx",91608],"6d7c6e65":[()=>Promise.all([n.e(1869),n.e(9431)]).then(n.bind(n,31583)),"@site/docs/guides/Installation/uninstalling.mdx",31583],"7230f7af":[()=>n.e(5017).then(n.bind(n,13536)),"@site/docs/guides/Debugging/metrics.md",13536],"7829a421":[()=>n.e(8149).then(n.bind(n,16430)),"@site/docs/guides/dora-drives/planning.mdx",16430],"7ac6915f":[()=>n.e(2611).then(n.bind(n,78532)),"@site/docs/api/dataflow-config.md",78532],"7d080400":[()=>n.e(8814).then(n.bind(n,89809)),"@site/docs/guides/Development/Arrow.md",89809],"814f3328":[()=>n.e(7472).then(n.t.bind(n,55513,19)),"~blog/default/blog-post-list-prop-default.json",55513],"83a61beb":[()=>n.e(3489).then(n.bind(n,23267)),"@site/docs/guides/dora-drives/readme.mdx",23267],"89af8042":[()=>Promise.all([n.e(1869),n.e(4105)]).then(n.bind(n,66374)),"@site/docs/guides/readme.mdx",66374],"8e3d7a31":[()=>n.e(7095).then(n.bind(n,59145)),"@site/docs/api/c-api.md",59145],"935f2afb":[()=>n.e(8581).then(n.t.bind(n,35610,19)),"~docs/default/version-current-metadata-prop-751.json",35610],"9456068e":[()=>n.e(3202).then(n.bind(n,33657)),"@site/docs/references/library-vs-framework.md",33657],"9e4087bc":[()=>n.e(2711).then(n.bind(n,89331)),"@theme/BlogArchivePage",89331],a4e81e67:[()=>n.e(3400).then(n.bind(n,52823)),"@site/docs/nodes_operators/pid_control_op.md",52823],a6aa9e1f:[()=>Promise.all([n.e(1869),n.e(5394),n.e(9911),n.e(4261),n.e(7643)]).then(n.bind(n,82052)),"@theme/BlogListPage",82052],a7bd4aaa:[()=>n.e(7098).then(n.bind(n,74532)),"@theme/DocVersionRoot",74532],a94703ab:[()=>Promise.all([n.e(1869),n.e(9048)]).then(n.bind(n,92559)),"@theme/DocRoot",92559],acecf23e:[()=>n.e(1903).then(n.t.bind(n,1912,19)),"~blog/default/blogMetadata-default.json",1912],b0d2d9e3:[()=>n.e(6590).then(n.bind(n,65276)),"@site/docs/footers/privacy-policy.md",65276],b2b675dd:[()=>n.e(1991).then(n.t.bind(n,29775,19)),"~blog/default/blog-c06.json",29775],b2f554cd:[()=>n.e(5894).then(n.t.bind(n,76042,19)),"~blog/default/blog-archive-80c.json",76042],b4f192e7:[()=>n.e(2099).then(n.bind(n,62870)),"@site/docs/nodes_operators/strong_sort_op.md",62870],bb14c781:[()=>n.e(8423).then(n.bind(n,43206)),"@site/docs/guides/dora-drives/carla.mdx",43206],c4f5d8e4:[()=>Promise.all([n.e(1869),n.e(5394),n.e(8148),n.e(2634)]).then(n.bind(n,78543)),"@site/src/pages/index.js",78543],c5f3a282:[()=>n.e(1893).then(n.bind(n,29447)),"@site/docs/guides/Installation/updating.mdx",29447],c77a962c:[()=>n.e(3373).then(n.t.bind(n,4061,19)),"/home/runner/work/dora-rs.github.io/dora-rs.github.io/.docusaurus/docusaurus-plugin-content-pages/default/plugin-route-context-module-100.json",4061],cc53d1e5:[()=>n.e(5982).then(n.bind(n,71177)),"@site/docs/nodes_operators/fot_op.md",71177],ccc49370:[()=>Promise.all([n.e(1869),n.e(5394),n.e(9911),n.e(4261),n.e(3249)]).then(n.bind(n,73858)),"@theme/BlogPostPage",73858],cdf3270e:[()=>n.e(6839).then(n.bind(n,57325)),"@site/docs/guides/Development/hot-reload.md",57325],d17ddd16:[()=>n.e(746).then(n.bind(n,26354)),"@site/docs/references/overview.md",26354],dd05a678:[()=>Promise.all([n.e(1869),n.e(5394),n.e(4939),n.e(2394)]).then(n.bind(n,80756)),"@site/docs/nodes/readme.mdx",80756],e3569af5:[()=>n.e(5707).then(n.bind(n,60921)),"@site/docs/guides/support-matrix.mdx",60921],f2406210:[()=>n.e(952).then(n.bind(n,73335)),"@site/docs/nodes_operators/webcam_op.md",73335],f4a8b054:[()=>n.e(8983).then(n.bind(n,53262)),"@site/docs/guides/Development/dynamic-node.md",53262]};var s=n(74848);function l(e){let{error:t,retry:n,pastDelay:r}=e;return t?(0,s.jsxs)("div",{style:{textAlign:"center",color:"#fff",backgroundColor:"#fa383e",borderColor:"#fa383e",borderStyle:"solid",borderRadius:"0.25rem",borderWidth:"1px",boxSizing:"border-box",display:"block",padding:"1rem",flex:"0 0 50%",marginLeft:"25%",marginRight:"25%",marginTop:"5rem",maxWidth:"50%",width:"100%"},children:[(0,s.jsx)("p",{children:String(t)}),(0,s.jsx)("div",{children:(0,s.jsx)("button",{type:"button",onClick:n,children:"Retry"})})]}):r?(0,s.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:(0,s.jsx)("svg",{id:"loader",style:{width:128,height:110,position:"absolute",top:"calc(100vh - 64%)"},viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",stroke:"#61dafb",children:(0,s.jsxs)("g",{fill:"none",fillRule:"evenodd",transform:"translate(1 1)",strokeWidth:"2",children:[(0,s.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,s.jsx)("animate",{attributeName:"r",begin:"1.5s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,s.jsx)("animate",{attributeName:"stroke-opacity",begin:"1.5s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,s.jsx)("animate",{attributeName:"stroke-width",begin:"1.5s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,s.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,s.jsx)("animate",{attributeName:"r",begin:"3s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,s.jsx)("animate",{attributeName:"stroke-opacity",begin:"3s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,s.jsx)("animate",{attributeName:"stroke-width",begin:"3s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,s.jsx)("circle",{cx:"22",cy:"22",r:"8",children:(0,s.jsx)("animate",{attributeName:"r",begin:"0s",dur:"1.5s",values:"6;1;2;3;4;5;6",calcMode:"linear",repeatCount:"indefinite"})})]})})}):null}var c=n(86921),u=n(53102);function d(e,t){if("*"===e)return a()({loading:l,loader:()=>n.e(2237).then(n.bind(n,82237)),modules:["@theme/NotFound"],webpack:()=>[82237],render(e,t){const n=e.default;return(0,s.jsx)(u.W,{value:{plugin:{name:"native",id:"default"}},children:(0,s.jsx)(n,{...t})})}});const r=o[`${e}-${t}`],d={},p=[],f=[],h=(0,c.A)(r);return Object.entries(h).forEach((e=>{let[t,n]=e;const r=i[n];r&&(d[t]=r[0],p.push(r[1]),f.push(r[2]))})),a().Map({loading:l,loader:d,modules:p,webpack:()=>f,render(t,n){const a=JSON.parse(JSON.stringify(r));Object.entries(t).forEach((t=>{let[n,r]=t;const o=r.default;if(!o)throw new Error(`The page component at ${e} doesn't have a default export. This makes it impossible to render anything. Consider default-exporting a React component.`);"object"!=typeof o&&"function"!=typeof o||Object.keys(r).filter((e=>"default"!==e)).forEach((e=>{o[e]=r[e]}));let i=a;const s=n.split(".");s.slice(0,-1).forEach((e=>{i=i[e]})),i[s[s.length-1]]=o}));const o=a.__comp;delete a.__comp;const i=a.__context;return delete a.__context,(0,s.jsx)(u.W,{value:i,children:(0,s.jsx)(o,{...a,...n})})}})}const p=[{path:"/blog",component:d("/blog","cc3"),exact:!0},{path:"/blog/archive",component:d("/blog/archive","2ec"),exact:!0},{path:"/blog/rust-python",component:d("/blog/rust-python","63a"),exact:!0},{path:"/installation-scripts",component:d("/installation-scripts","d79"),exact:!0},{path:"/search",component:d("/search","a28"),exact:!0},{path:"/docs",component:d("/docs","219"),routes:[{path:"/docs",component:d("/docs","f04"),routes:[{path:"/docs",component:d("/docs","f99"),routes:[{path:"/docs/api/c-api",component:d("/docs/api/c-api","0f2"),exact:!0},{path:"/docs/api/cli",component:d("/docs/api/cli","88f"),exact:!0},{path:"/docs/api/dataflow-config",component:d("/docs/api/dataflow-config","f68"),exact:!0},{path:"/docs/examples/",component:d("/docs/examples/","882"),exact:!0,sidebar:"examples"},{path:"/docs/footers/privacy-policy",component:d("/docs/footers/privacy-policy","a65"),exact:!0},{path:"/docs/guides/",component:d("/docs/guides/","f2d"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Debugging/logs",component:d("/docs/guides/Debugging/logs","56a"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Debugging/metrics",component:d("/docs/guides/Debugging/metrics","393"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Debugging/tracing",component:d("/docs/guides/Debugging/tracing","dd9"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Development/Arrow",component:d("/docs/guides/Development/Arrow","abd"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Development/Cuda",component:d("/docs/guides/Development/Cuda","c10"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Development/dynamic-node",component:d("/docs/guides/Development/dynamic-node","708"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Development/hot-reload",component:d("/docs/guides/Development/hot-reload","a47"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-drives/",component:d("/docs/guides/dora-drives/","f8b"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-drives/carla",component:d("/docs/guides/dora-drives/carla","4a2"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-drives/control",component:d("/docs/guides/dora-drives/control","2a3"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-drives/installation",component:d("/docs/guides/dora-drives/installation","d03"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-drives/obstacle_location",component:d("/docs/guides/dora-drives/obstacle_location","d3f"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-drives/planning",component:d("/docs/guides/dora-drives/planning","ca2"),exact:!0,sidebar:"guides"},{path:"/docs/guides/dora-ros2-bridges/",component:d("/docs/guides/dora-ros2-bridges/","103"),exact:!0,sidebar:"guides"},{path:"/docs/guides/getting-started/conversation_py",component:d("/docs/guides/getting-started/conversation_py","3bf"),exact:!0,sidebar:"guides"},{path:"/docs/guides/getting-started/llm",component:d("/docs/guides/getting-started/llm","540"),exact:!0,sidebar:"guides"},{path:"/docs/guides/getting-started/webcam_plot",component:d("/docs/guides/getting-started/webcam_plot","771"),exact:!0,sidebar:"guides"},{path:"/docs/guides/getting-started/yolov8",component:d("/docs/guides/getting-started/yolov8","166"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Installation/installing",component:d("/docs/guides/Installation/installing","93d"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Installation/uninstalling",component:d("/docs/guides/Installation/uninstalling","284"),exact:!0,sidebar:"guides"},{path:"/docs/guides/Installation/updating",component:d("/docs/guides/Installation/updating","681"),exact:!0,sidebar:"guides"},{path:"/docs/guides/support-matrix",component:d("/docs/guides/support-matrix","5c2"),exact:!0,sidebar:"guides"},{path:"/docs/nodes_operators/fot_op",component:d("/docs/nodes_operators/fot_op","09b"),exact:!0},{path:"/docs/nodes_operators/midas_op",component:d("/docs/nodes_operators/midas_op","528"),exact:!0},{path:"/docs/nodes_operators/obstacle_location_op",component:d("/docs/nodes_operators/obstacle_location_op","c44"),exact:!0},{path:"/docs/nodes_operators/pid_control_op",component:d("/docs/nodes_operators/pid_control_op","abb"),exact:!0},{path:"/docs/nodes_operators/plot",component:d("/docs/nodes_operators/plot","1f2"),exact:!0},{path:"/docs/nodes_operators/strong_sort_op",component:d("/docs/nodes_operators/strong_sort_op","9b0"),exact:!0},{path:"/docs/nodes_operators/webcam_op",component:d("/docs/nodes_operators/webcam_op","6ca"),exact:!0},{path:"/docs/nodes_operators/yolop_op",component:d("/docs/nodes_operators/yolop_op","1a0"),exact:!0},{path:"/docs/nodes_operators/yolov5_op",component:d("/docs/nodes_operators/yolov5_op","4c8"),exact:!0},{path:"/docs/nodes/",component:d("/docs/nodes/","a9c"),exact:!0,sidebar:"nodes"},{path:"/docs/references/",component:d("/docs/references/","9e2"),exact:!0,sidebar:"references"},{path:"/docs/references/communication-layer",component:d("/docs/references/communication-layer","27f"),exact:!0,sidebar:"references"},{path:"/docs/references/library-vs-framework",component:d("/docs/references/library-vs-framework","cd3"),exact:!0,sidebar:"references"},{path:"/docs/references/overview",component:d("/docs/references/overview","6ae"),exact:!0,sidebar:"references"},{path:"/docs/references/state-management",component:d("/docs/references/state-management","208"),exact:!0,sidebar:"references"}]}]}]},{path:"/",component:d("/","ff5"),exact:!0},{path:"*",component:d("*")}]},6125:(e,t,n)=>{"use strict";n.d(t,{o:()=>o,x:()=>i});var r=n(96540),a=n(74848);const o=r.createContext(!1);function i(e){let{children:t}=e;const[n,i]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{i(!0)}),[]),(0,a.jsx)(o.Provider,{value:n,children:t})}},38536:(e,t,n)=>{"use strict";var r=n(96540),a=n(5338),o=n(54625),i=n(80545),s=n(38193);const l=[n(10119),n(26134),n(76294),n(51043)];var c=n(35947),u=n(56347),d=n(22831),p=n(74848);function f(e){let{children:t}=e;return(0,p.jsx)(p.Fragment,{children:t})}var h=n(5260),g=n(44586),m=n(86025),b=n(6342),y=n(45500),v=n(32131),w=n(14090),k=n(2967),x=n(70440),S=n(41463);function _(){const{i18n:{currentLocale:e,defaultLocale:t,localeConfigs:n}}=(0,g.A)(),r=(0,v.o)(),a=n[e].htmlLang,o=e=>e.replace("-","_");return(0,p.jsxs)(h.A,{children:[Object.entries(n).map((e=>{let[t,{htmlLang:n}]=e;return(0,p.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:n},t)})),(0,p.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:"x-default"}),(0,p.jsx)("meta",{property:"og:locale",content:o(a)}),Object.values(n).filter((e=>a!==e.htmlLang)).map((e=>(0,p.jsx)("meta",{property:"og:locale:alternate",content:o(e.htmlLang)},`meta-og-${e.htmlLang}`)))]})}function E(e){let{permalink:t}=e;const{siteConfig:{url:n}}=(0,g.A)(),r=function(){const{siteConfig:{url:e,baseUrl:t,trailingSlash:n}}=(0,g.A)(),{pathname:r}=(0,u.zy)();return e+(0,x.applyTrailingSlash)((0,m.A)(r),{trailingSlash:n,baseUrl:t})}(),a=t?`${n}${t}`:r;return(0,p.jsxs)(h.A,{children:[(0,p.jsx)("meta",{property:"og:url",content:a}),(0,p.jsx)("link",{rel:"canonical",href:a})]})}function C(){const{i18n:{currentLocale:e}}=(0,g.A)(),{metadata:t,image:n}=(0,b.p)();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(h.A,{children:[(0,p.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,p.jsx)("body",{className:w.w})]}),n&&(0,p.jsx)(y.be,{image:n}),(0,p.jsx)(E,{}),(0,p.jsx)(_,{}),(0,p.jsx)(S.A,{tag:k.Cy,locale:e}),(0,p.jsx)(h.A,{children:t.map(((e,t)=>(0,p.jsx)("meta",{...e},t)))})]})}const T=new Map;function A(e){if(T.has(e.pathname))return{...e,pathname:T.get(e.pathname)};if((0,d.u)(c.A,e.pathname).some((e=>{let{route:t}=e;return!0===t.exact})))return T.set(e.pathname,e.pathname),e;const t=e.pathname.trim().replace(/(?:\/index)?\.html$/,"")||"/";return T.set(e.pathname,t),{...e,pathname:t}}var N=n(6125),L=n(26988),P=n(205);function R(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const r=t.default?.[e]??t[e];return r?.(...n)}));return()=>a.forEach((e=>e?.()))}const O=function(e){let{children:t,location:n,previousLocation:r}=e;return(0,P.A)((()=>{r!==n&&(!function(e){let{location:t,previousLocation:n}=e;if(!n)return;const r=t.pathname===n.pathname,a=t.hash===n.hash,o=t.search===n.search;if(r&&a&&!o)return;const{hash:i}=t;if(i){const e=decodeURIComponent(i.substring(1)),t=document.getElementById(e);t?.scrollIntoView()}else window.scrollTo(0,0)}({location:n,previousLocation:r}),R("onRouteDidUpdate",{previousLocation:r,location:n}))}),[r,n]),t};function j(e){const t=Array.from(new Set([e,decodeURI(e)])).map((e=>(0,d.u)(c.A,e))).flat();return Promise.all(t.map((e=>e.route.component.preload?.())))}class I extends r.Component{previousLocation;routeUpdateCleanupCb;constructor(e){super(e),this.previousLocation=null,this.routeUpdateCleanupCb=s.A.canUseDOM?R("onRouteUpdate",{previousLocation:null,location:this.props.location}):()=>{},this.state={nextRouteHasLoaded:!0}}shouldComponentUpdate(e,t){if(e.location===this.props.location)return t.nextRouteHasLoaded;const n=e.location;return this.previousLocation=this.props.location,this.setState({nextRouteHasLoaded:!1}),this.routeUpdateCleanupCb=R("onRouteUpdate",{previousLocation:this.previousLocation,location:n}),j(n.pathname).then((()=>{this.routeUpdateCleanupCb(),this.setState({nextRouteHasLoaded:!0})})).catch((e=>{console.warn(e),window.location.reload()})),!1}render(){const{children:e,location:t}=this.props;return(0,p.jsx)(O,{previousLocation:this.previousLocation,location:t,children:(0,p.jsx)(u.qh,{location:t,render:()=>e})})}}const D=I,M="__docusaurus-base-url-issue-banner-container",F="__docusaurus-base-url-issue-banner",B="__docusaurus-base-url-issue-banner-suggestion-container";function z(e){return`\ndocument.addEventListener('DOMContentLoaded', function maybeInsertBanner() {\n var shouldInsert = typeof window['docusaurus'] === 'undefined';\n shouldInsert && insertBanner();\n});\n\nfunction insertBanner() {\n var bannerContainer = document.createElement('div');\n bannerContainer.id = '${M}';\n var bannerHtml = ${JSON.stringify(function(e){return`\n
\n

Your Docusaurus site did not load properly.

\n

A very common reason is a wrong site baseUrl configuration.

\n

Current configured baseUrl = ${e} ${"/"===e?" (default value)":""}

\n

We suggest trying baseUrl =

\n
\n`}(e)).replace(/{if("undefined"==typeof document)return void n();const r=document.createElement("link");r.setAttribute("rel","prefetch"),r.setAttribute("href",e),r.onload=()=>t(),r.onerror=()=>n();const a=document.getElementsByTagName("head")[0]??document.getElementsByName("script")[0]?.parentNode;a?.appendChild(r)}))}:function(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.withCredentials=!0,r.onload=()=>{200===r.status?t():n()},r.send(null)}))};var Q=n(86921);const Z=new Set,X=new Set,J=()=>navigator.connection?.effectiveType.includes("2g")||navigator.connection?.saveData,ee={prefetch(e){if(!(e=>!J()&&!X.has(e)&&!Z.has(e))(e))return!1;Z.add(e);const t=(0,d.u)(c.A,e).flatMap((e=>{return t=e.route.path,Object.entries(K).filter((e=>{let[n]=e;return n.replace(/-[^-]+$/,"")===t})).flatMap((e=>{let[,t]=e;return Object.values((0,Q.A)(t))}));var t}));return Promise.all(t.map((e=>{const t=n.gca(e);return t&&!t.includes("undefined")?Y(t).catch((()=>{})):Promise.resolve()})))},preload:e=>!!(e=>!J()&&!X.has(e))(e)&&(X.add(e),j(e))},te=Object.freeze(ee),ne=Boolean(!0);if(s.A.canUseDOM){window.docusaurus=te;const e=document.getElementById("__docusaurus"),t=(0,p.jsx)(i.vd,{children:(0,p.jsx)(o.Kd,{children:(0,p.jsx)(q,{})})}),n=(e,t)=>{console.error("Docusaurus React Root onRecoverableError:",e,t)},s=()=>{if(ne)r.startTransition((()=>{a.hydrateRoot(e,t,{onRecoverableError:n})}));else{const o=a.createRoot(e,{onRecoverableError:n});r.startTransition((()=>{o.render(t)}))}};j(window.location.pathname).then(s)}},26988:(e,t,n)=>{"use strict";n.d(t,{o:()=>d,l:()=>p});var r=n(96540),a=n(4784);const o=JSON.parse('{"docusaurus-plugin-content-docs":{"default":{"path":"/docs","versions":[{"name":"current","label":"Next","isLast":true,"path":"/docs","mainDocId":"guides/readme","docs":[{"id":"api/c-api","path":"/docs/api/c-api"},{"id":"api/cli","path":"/docs/api/cli"},{"id":"api/dataflow-config","path":"/docs/api/dataflow-config"},{"id":"examples/readme","path":"/docs/examples/","sidebar":"examples"},{"id":"footers/privacy-policy","path":"/docs/footers/privacy-policy"},{"id":"guides/Debugging/logs","path":"/docs/guides/Debugging/logs","sidebar":"guides"},{"id":"guides/Debugging/metrics","path":"/docs/guides/Debugging/metrics","sidebar":"guides"},{"id":"guides/Debugging/tracing","path":"/docs/guides/Debugging/tracing","sidebar":"guides"},{"id":"guides/Development/Arrow","path":"/docs/guides/Development/Arrow","sidebar":"guides"},{"id":"guides/Development/Cuda","path":"/docs/guides/Development/Cuda","sidebar":"guides"},{"id":"guides/Development/dynamic-node","path":"/docs/guides/Development/dynamic-node","sidebar":"guides"},{"id":"guides/Development/hot-reload","path":"/docs/guides/Development/hot-reload","sidebar":"guides"},{"id":"guides/dora-drives/carla","path":"/docs/guides/dora-drives/carla","sidebar":"guides"},{"id":"guides/dora-drives/control","path":"/docs/guides/dora-drives/control","sidebar":"guides"},{"id":"guides/dora-drives/installation","path":"/docs/guides/dora-drives/installation","sidebar":"guides"},{"id":"guides/dora-drives/obstacle_location","path":"/docs/guides/dora-drives/obstacle_location","sidebar":"guides"},{"id":"guides/dora-drives/planning","path":"/docs/guides/dora-drives/planning","sidebar":"guides"},{"id":"guides/dora-drives/readme","path":"/docs/guides/dora-drives/","sidebar":"guides"},{"id":"guides/dora-ros2-bridges/dora-ros2-bridges","path":"/docs/guides/dora-ros2-bridges/","sidebar":"guides"},{"id":"guides/getting-started/conversation_py","path":"/docs/guides/getting-started/conversation_py","sidebar":"guides"},{"id":"guides/getting-started/llm","path":"/docs/guides/getting-started/llm","sidebar":"guides"},{"id":"guides/getting-started/webcam_plot","path":"/docs/guides/getting-started/webcam_plot","sidebar":"guides"},{"id":"guides/getting-started/yolov8","path":"/docs/guides/getting-started/yolov8","sidebar":"guides"},{"id":"guides/Installation/installing","path":"/docs/guides/Installation/installing","sidebar":"guides"},{"id":"guides/Installation/uninstalling","path":"/docs/guides/Installation/uninstalling","sidebar":"guides"},{"id":"guides/Installation/updating","path":"/docs/guides/Installation/updating","sidebar":"guides"},{"id":"guides/readme","path":"/docs/guides/","sidebar":"guides"},{"id":"guides/support-matrix","path":"/docs/guides/support-matrix","sidebar":"guides"},{"id":"nodes_operators/fot_op","path":"/docs/nodes_operators/fot_op"},{"id":"nodes_operators/midas_op","path":"/docs/nodes_operators/midas_op"},{"id":"nodes_operators/obstacle_location_op","path":"/docs/nodes_operators/obstacle_location_op"},{"id":"nodes_operators/pid_control_op","path":"/docs/nodes_operators/pid_control_op"},{"id":"nodes_operators/plot","path":"/docs/nodes_operators/plot"},{"id":"nodes_operators/strong_sort_op","path":"/docs/nodes_operators/strong_sort_op"},{"id":"nodes_operators/webcam_op","path":"/docs/nodes_operators/webcam_op"},{"id":"nodes_operators/yolop_op","path":"/docs/nodes_operators/yolop_op"},{"id":"nodes_operators/yolov5_op","path":"/docs/nodes_operators/yolov5_op"},{"id":"nodes/readme","path":"/docs/nodes/","sidebar":"nodes"},{"id":"references/communication-layer","path":"/docs/references/communication-layer","sidebar":"references"},{"id":"references/library-vs-framework","path":"/docs/references/library-vs-framework","sidebar":"references"},{"id":"references/overview","path":"/docs/references/overview","sidebar":"references"},{"id":"references/readme","path":"/docs/references/","sidebar":"references"},{"id":"references/state-management","path":"/docs/references/state-management","sidebar":"references"}],"draftIds":[],"sidebars":{"guides":{"link":{"path":"/docs/guides/","label":"Guides"}},"references":{"link":{"path":"/docs/references/","label":"References"}},"examples":{"link":{"path":"/docs/examples/","label":"Examples"}},"nodes":{"link":{"path":"/docs/nodes/","label":"Nodes"}}}}],"breadcrumbs":true}}}'),i=JSON.parse('{"defaultLocale":"en","locales":["en","zh-CN"],"path":"i18n","currentLocale":"en","localeConfigs":{"en":{"label":"English","direction":"ltr","htmlLang":"en","calendar":"gregory","path":"en"},"zh-CN":{"label":"\u4e2d\u6587\uff08\u4e2d\u56fd\uff09","direction":"ltr","htmlLang":"zh-CN","calendar":"gregory","path":"zh-CN"}}}');var s=n(22654);const l=JSON.parse('{"docusaurusVersion":"3.2.0","siteVersion":"0.0.0","pluginVersions":{"docusaurus-plugin-content-docs":{"type":"package","name":"@docusaurus/plugin-content-docs","version":"3.2.0"},"docusaurus-plugin-content-blog":{"type":"package","name":"@docusaurus/plugin-content-blog","version":"3.2.0"},"docusaurus-plugin-content-pages":{"type":"package","name":"@docusaurus/plugin-content-pages","version":"3.2.0"},"docusaurus-plugin-sitemap":{"type":"package","name":"@docusaurus/plugin-sitemap","version":"3.2.0"},"docusaurus-theme-classic":{"type":"package","name":"@docusaurus/theme-classic","version":"3.2.0"},"docusaurus-theme-search-algolia":{"type":"package","name":"@docusaurus/theme-search-algolia","version":"3.2.0"},"docusaurus-theme-mermaid":{"type":"package","name":"@docusaurus/theme-mermaid","version":"3.2.0"}}}');var c=n(74848);const u={siteConfig:a.default,siteMetadata:l,globalData:o,i18n:i,codeTranslations:s},d=r.createContext(u);function p(e){let{children:t}=e;return(0,c.jsx)(d.Provider,{value:u,children:t})}},67489:(e,t,n)=>{"use strict";n.d(t,{A:()=>g});var r=n(96540),a=n(38193),o=n(5260),i=n(70440),s=n(44561),l=n(53102),c=n(74848);function u(e){let{error:t,tryAgain:n}=e;return(0,c.jsxs)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",minHeight:"100vh",width:"100%",maxWidth:"80ch",fontSize:"20px",margin:"0 auto",padding:"1rem"},children:[(0,c.jsx)("h1",{style:{fontSize:"3rem"},children:"This page crashed"}),(0,c.jsx)("button",{type:"button",onClick:n,style:{margin:"1rem 0",fontSize:"2rem",cursor:"pointer",borderRadius:20,padding:"1rem"},children:"Try again"}),(0,c.jsx)(d,{error:t})]})}function d(e){let{error:t}=e;const n=(0,i.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,c.jsx)("p",{style:{whiteSpace:"pre-wrap"},children:n})}function p(e){let{children:t}=e;return(0,c.jsx)(l.W,{value:{plugin:{name:"docusaurus-core-error-boundary",id:"default"}},children:t})}function f(e){let{error:t,tryAgain:n}=e;return(0,c.jsx)(p,{children:(0,c.jsxs)(g,{fallback:()=>(0,c.jsx)(u,{error:t,tryAgain:n}),children:[(0,c.jsx)(o.A,{children:(0,c.jsx)("title",{children:"Page Error"})}),(0,c.jsx)(s.A,{children:(0,c.jsx)(u,{error:t,tryAgain:n})})]})})}const h=e=>(0,c.jsx)(f,{...e});class g extends r.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){a.A.canUseDOM&&this.setState({error:e})}render(){const{children:e}=this.props,{error:t}=this.state;if(t){const e={error:t,tryAgain:()=>this.setState({error:null})};return(this.props.fallback??h)(e)}return e??null}}},38193:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});const r="undefined"!=typeof window&&"document"in window&&"createElement"in window.document,a={canUseDOM:r,canUseEventListeners:r&&("addEventListener"in window||"attachEvent"in window),canUseIntersectionObserver:r&&"IntersectionObserver"in window,canUseViewport:r&&"screen"in window}},5260:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(96540);var r=n(80545),a=n(74848);function o(e){return(0,a.jsx)(r.mg,{...e})}},28774:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(96540),a=n(54625),o=n(70440),i=n(44586),s=n(16654),l=n(38193),c=n(63427),u=n(86025),d=n(74848);function p(e,t){let{isNavLink:n,to:p,href:f,activeClassName:h,isActive:g,"data-noBrokenLinkCheck":m,autoAddBaseUrl:b=!0,...y}=e;const{siteConfig:{trailingSlash:v,baseUrl:w}}=(0,i.A)(),{withBaseUrl:k}=(0,u.h)(),x=(0,c.A)(),S=(0,r.useRef)(null);(0,r.useImperativeHandle)(t,(()=>S.current));const _=p||f;const E=(0,s.A)(_),C=_?.replace("pathname://","");let T=void 0!==C?(A=C,b&&(e=>e.startsWith("/"))(A)?k(A):A):void 0;var A;T&&E&&(T=(0,o.applyTrailingSlash)(T,{trailingSlash:v,baseUrl:w}));const N=(0,r.useRef)(!1),L=n?a.k2:a.N_,P=l.A.canUseIntersectionObserver,R=(0,r.useRef)(),O=()=>{N.current||null==T||(window.docusaurus.preload(T),N.current=!0)};(0,r.useEffect)((()=>(!P&&E&&null!=T&&window.docusaurus.prefetch(T),()=>{P&&R.current&&R.current.disconnect()})),[R,T,P,E]);const j=T?.startsWith("#")??!1,I=!y.target||"_self"===y.target,D=!T||!E||!I||j;return m||!j&&D||x.collectLink(T),y.id&&x.collectAnchor(y.id),D?(0,d.jsx)("a",{ref:S,href:T,..._&&!E&&{target:"_blank",rel:"noopener noreferrer"},...y}):(0,d.jsx)(L,{...y,onMouseEnter:O,onTouchStart:O,innerRef:e=>{S.current=e,P&&e&&E&&(R.current=new window.IntersectionObserver((t=>{t.forEach((t=>{e===t.target&&(t.isIntersecting||t.intersectionRatio>0)&&(R.current.unobserve(e),R.current.disconnect(),null!=T&&window.docusaurus.prefetch(T))}))})),R.current.observe(e))},to:T,...n&&{isActive:g,activeClassName:h}})}const f=r.forwardRef(p)},21312:(e,t,n)=>{"use strict";n.d(t,{A:()=>c,T:()=>l});var r=n(96540),a=n(74848);function o(e,t){const n=e.split(/(\{\w+\})/).map(((e,n)=>{if(n%2==1){const n=t?.[e.slice(1,-1)];if(void 0!==n)return n}return e}));return n.some((e=>(0,r.isValidElement)(e)))?n.map(((e,t)=>(0,r.isValidElement)(e)?r.cloneElement(e,{key:t}):e)).filter((e=>""!==e)):n.join("")}var i=n(22654);function s(e){let{id:t,message:n}=e;if(void 0===t&&void 0===n)throw new Error("Docusaurus translation declarations must have at least a translation id or a default translation message");return i[t??n]??n??t}function l(e,t){let{message:n,id:r}=e;return o(s({message:n,id:r}),t)}function c(e){let{children:t,id:n,values:r}=e;if(t&&"string"!=typeof t)throw console.warn("Illegal children",t),new Error("The Docusaurus component only accept simple string values");const i=s({message:t,id:n});return(0,a.jsx)(a.Fragment,{children:o(i,r)})}},17065:(e,t,n)=>{"use strict";n.d(t,{W:()=>r});const r="default"},16654:(e,t,n)=>{"use strict";function r(e){return/^(?:\w*:|\/\/)/.test(e)}function a(e){return void 0!==e&&!r(e)}n.d(t,{A:()=>a,z:()=>r})},86025:(e,t,n)=>{"use strict";n.d(t,{A:()=>s,h:()=>i});var r=n(96540),a=n(44586),o=n(16654);function i(){const{siteConfig:{baseUrl:e,url:t}}=(0,a.A)(),n=(0,r.useCallback)(((n,r)=>function(e,t,n,r){let{forcePrependBaseUrl:a=!1,absolute:i=!1}=void 0===r?{}:r;if(!n||n.startsWith("#")||(0,o.z)(n))return n;if(a)return t+n.replace(/^\//,"");if(n===t.replace(/\/$/,""))return t;const s=n.startsWith(t)?n:t+n.replace(/^\//,"");return i?e+s:s}(t,e,n,r)),[t,e]);return{withBaseUrl:n}}function s(e,t){void 0===t&&(t={});const{withBaseUrl:n}=i();return n(e,t)}},63427:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(96540);n(74848);const a=r.createContext({collectAnchor:()=>{},collectLink:()=>{}}),o=()=>(0,r.useContext)(a);function i(){return o()}},44586:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(96540),a=n(26988);function o(){return(0,r.useContext)(a.o)}},92303:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(96540),a=n(6125);function o(){return(0,r.useContext)(a.o)}},205:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(96540);const a=n(38193).A.canUseDOM?r.useLayoutEffect:r.useEffect},36803:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(96540),a=n(53102);function o(){const e=r.useContext(a.o);if(!e)throw new Error("Unexpected: no Docusaurus route context found");return e}},86921:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});const r=e=>"object"==typeof e&&!!e&&Object.keys(e).length>0;function a(e){const t={};return function e(n,a){Object.entries(n).forEach((n=>{let[o,i]=n;const s=a?`${a}.${o}`:o;r(i)?e(i,s):t[s]=i}))}(e),t}},53102:(e,t,n)=>{"use strict";n.d(t,{W:()=>i,o:()=>o});var r=n(96540),a=n(74848);const o=r.createContext(null);function i(e){let{children:t,value:n}=e;const i=r.useContext(o),s=(0,r.useMemo)((()=>function(e){let{parent:t,value:n}=e;if(!t){if(!n)throw new Error("Unexpected: no Docusaurus route context found");if(!("plugin"in n))throw new Error("Unexpected: Docusaurus topmost route context has no `plugin` attribute");return n}const r={...t.data,...n?.data};return{plugin:t.plugin,data:r}}({parent:i,value:n})),[i,n]);return(0,a.jsx)(o.Provider,{value:s,children:t})}},44070:(e,t,n)=>{"use strict";n.d(t,{zK:()=>b,vT:()=>f,gk:()=>h,Gy:()=>d,HW:()=>y,ht:()=>p,r7:()=>m,jh:()=>g});var r=n(56347),a=n(44586),o=n(17065);function i(e,t){void 0===t&&(t={});const n=function(){const{globalData:e}=(0,a.A)();return e}()[e];if(!n&&t.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin.`);return n}const s=e=>e.versions.find((e=>e.isLast));function l(e,t){const n=s(e);return[...e.versions.filter((e=>e!==n)),n].find((e=>!!(0,r.B6)(t,{path:e.path,exact:!1,strict:!1})))}function c(e,t){const n=l(e,t),a=n?.docs.find((e=>!!(0,r.B6)(t,{path:e.path,exact:!0,strict:!1})));return{activeVersion:n,activeDoc:a,alternateDocVersions:a?function(t){const n={};return e.versions.forEach((e=>{e.docs.forEach((r=>{r.id===t&&(n[e.name]=r)}))})),n}(a.id):{}}}const u={},d=()=>i("docusaurus-plugin-content-docs")??u,p=e=>{try{return function(e,t,n){void 0===t&&(t=o.W),void 0===n&&(n={});const r=i(e),a=r?.[t];if(!a&&n.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin with id "${t}".`);return a}("docusaurus-plugin-content-docs",e,{failfast:!0})}catch(t){throw new Error("You are using a feature of the Docusaurus docs plugin, but this plugin does not seem to be enabled"+("Default"===e?"":` (pluginId=${e}`),{cause:t})}};function f(e){void 0===e&&(e={});const t=d(),{pathname:n}=(0,r.zy)();return function(e,t,n){void 0===n&&(n={});const a=Object.entries(e).sort(((e,t)=>t[1].path.localeCompare(e[1].path))).find((e=>{let[,n]=e;return!!(0,r.B6)(t,{path:n.path,exact:!1,strict:!1})})),o=a?{pluginId:a[0],pluginData:a[1]}:void 0;if(!o&&n.failfast)throw new Error(`Can't find active docs plugin for "${t}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(e).map((e=>e.path)).join(", ")}`);return o}(t,n,e)}function h(e){void 0===e&&(e={});const t=f(e),{pathname:n}=(0,r.zy)();if(!t)return;return{activePlugin:t,activeVersion:l(t.pluginData,n)}}function g(e){return p(e).versions}function m(e){const t=p(e);return s(t)}function b(e){const t=p(e),{pathname:n}=(0,r.zy)();return c(t,n)}function y(e){const t=p(e),{pathname:n}=(0,r.zy)();return function(e,t){const n=s(e);return{latestDocSuggestion:c(e,t).alternateDocVersions[n.name],latestVersionSuggestion:n}}(t,n)}},76294:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(5947),a=n.n(r);a().configure({showSpinner:!1});const o={onRouteUpdate(e){let{location:t,previousLocation:n}=e;if(n&&t.pathname!==n.pathname){const e=window.setTimeout((()=>{a().start()}),200);return()=>window.clearTimeout(e)}},onRouteDidUpdate(){a().done()}}},26134:(e,t,n)=>{"use strict";n.r(t);var r=n(84876),a=n(4784);!function(e){const{themeConfig:{prism:t}}=a.default,{additionalLanguages:r}=t;globalThis.Prism=e,r.forEach((e=>{"php"===e&&n(19700),n(10900)(`./prism-${e}`)})),delete globalThis.Prism}(r.My)},51107:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});n(96540);var r=n(18215),a=n(21312),o=n(6342),i=n(28774),s=n(63427);const l={anchorWithStickyNavbar:"anchorWithStickyNavbar_LWe7",anchorWithHideOnScrollNavbar:"anchorWithHideOnScrollNavbar_WYt5"};var c=n(74848);function u(e){let{as:t,id:n,...u}=e;const d=(0,s.A)(),{navbar:{hideOnScroll:p}}=(0,o.p)();if("h1"===t||!n)return(0,c.jsx)(t,{...u,id:void 0});d.collectAnchor(n);const f=(0,a.T)({id:"theme.common.headingLinkTitle",message:"Direct link to {heading}",description:"Title for link to heading"},{heading:"string"==typeof u.children?u.children:n});return(0,c.jsxs)(t,{...u,className:(0,r.A)("anchor",p?l.anchorWithHideOnScrollNavbar:l.anchorWithStickyNavbar,u.className),id:n,children:[u.children,(0,c.jsx)(i.A,{className:"hash-link",to:`#${n}`,"aria-label":f,title:f,children:"\u200b"})]})}},43186:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(96540);const r={iconExternalLink:"iconExternalLink_nPIU"};var a=n(74848);function o(e){let{width:t=13.5,height:n=13.5}=e;return(0,a.jsx)("svg",{width:t,height:n,"aria-hidden":"true",viewBox:"0 0 24 24",className:r.iconExternalLink,children:(0,a.jsx)("path",{fill:"currentColor",d:"M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"})})}},44561:(e,t,n)=>{"use strict";n.d(t,{A:()=>Nt});var r=n(96540),a=n(18215),o=n(67489),i=n(45500),s=n(56347),l=n(21312),c=n(75062),u=n(74848);const d="__docusaurus_skipToContent_fallback";function p(e){e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")}function f(){const e=(0,r.useRef)(null),{action:t}=(0,s.W6)(),n=(0,r.useCallback)((e=>{e.preventDefault();const t=document.querySelector("main:first-of-type")??document.getElementById(d);t&&p(t)}),[]);return(0,c.$)((n=>{let{location:r}=n;e.current&&!r.hash&&"PUSH"===t&&p(e.current)})),{containerRef:e,onClick:n}}const h=(0,l.T)({id:"theme.common.skipToMainContent",description:"The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation",message:"Skip to main content"});function g(e){const t=e.children??h,{containerRef:n,onClick:r}=f();return(0,u.jsx)("div",{ref:n,role:"region","aria-label":h,children:(0,u.jsx)("a",{...e,href:`#${d}`,onClick:r,children:t})})}var m=n(17559),b=n(14090);const y={skipToContent:"skipToContent_fXgn"};function v(){return(0,u.jsx)(g,{className:y.skipToContent})}var w=n(6342),k=n(65041);function x(e){let{width:t=21,height:n=21,color:r="currentColor",strokeWidth:a=1.2,className:o,...i}=e;return(0,u.jsx)("svg",{viewBox:"0 0 15 15",width:t,height:n,...i,children:(0,u.jsx)("g",{stroke:r,strokeWidth:a,children:(0,u.jsx)("path",{d:"M.75.75l13.5 13.5M14.25.75L.75 14.25"})})})}const S={closeButton:"closeButton_CVFx"};function _(e){return(0,u.jsx)("button",{type:"button","aria-label":(0,l.T)({id:"theme.AnnouncementBar.closeButtonAriaLabel",message:"Close",description:"The ARIA label for close button of announcement bar"}),...e,className:(0,a.A)("clean-btn close",S.closeButton,e.className),children:(0,u.jsx)(x,{width:14,height:14,strokeWidth:3.1})})}const E={content:"content_knG7"};function C(e){const{announcementBar:t}=(0,w.p)(),{content:n}=t;return(0,u.jsx)("div",{...e,className:(0,a.A)(E.content,e.className),dangerouslySetInnerHTML:{__html:n}})}const T={announcementBar:"announcementBar_mb4j",announcementBarPlaceholder:"announcementBarPlaceholder_vyr4",announcementBarClose:"announcementBarClose_gvF7",announcementBarContent:"announcementBarContent_xLdY"};function A(){const{announcementBar:e}=(0,w.p)(),{isActive:t,close:n}=(0,k.Mj)();if(!t)return null;const{backgroundColor:r,textColor:a,isCloseable:o}=e;return(0,u.jsxs)("div",{className:T.announcementBar,style:{backgroundColor:r,color:a},role:"banner",children:[o&&(0,u.jsx)("div",{className:T.announcementBarPlaceholder}),(0,u.jsx)(C,{className:T.announcementBarContent}),o&&(0,u.jsx)(_,{onClick:n,className:T.announcementBarClose})]})}var N=n(22069),L=n(23104);var P=n(89532),R=n(75600);const O=r.createContext(null);function j(e){let{children:t}=e;const n=function(){const e=(0,N.M)(),t=(0,R.YL)(),[n,a]=(0,r.useState)(!1),o=null!==t.component,i=(0,P.ZC)(o);return(0,r.useEffect)((()=>{o&&!i&&a(!0)}),[o,i]),(0,r.useEffect)((()=>{o?e.shown||a(!0):a(!1)}),[e.shown,o]),(0,r.useMemo)((()=>[n,a]),[n])}();return(0,u.jsx)(O.Provider,{value:n,children:t})}function I(e){if(e.component){const t=e.component;return(0,u.jsx)(t,{...e.props})}}function D(){const e=(0,r.useContext)(O);if(!e)throw new P.dV("NavbarSecondaryMenuDisplayProvider");const[t,n]=e,a=(0,r.useCallback)((()=>n(!1)),[n]),o=(0,R.YL)();return(0,r.useMemo)((()=>({shown:t,hide:a,content:I(o)})),[a,o,t])}function M(e){let{header:t,primaryMenu:n,secondaryMenu:r}=e;const{shown:o}=D();return(0,u.jsxs)("div",{className:"navbar-sidebar",children:[t,(0,u.jsxs)("div",{className:(0,a.A)("navbar-sidebar__items",{"navbar-sidebar__items--show-secondary":o}),children:[(0,u.jsx)("div",{className:"navbar-sidebar__item menu",children:n}),(0,u.jsx)("div",{className:"navbar-sidebar__item menu",children:r})]})]})}var F=n(95293),B=n(92303);function z(e){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"})})}function $(e){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"})})}const U={toggle:"toggle_vylO",toggleButton:"toggleButton_gllP",darkToggleIcon:"darkToggleIcon_wfgR",lightToggleIcon:"lightToggleIcon_pyhR",toggleButtonDisabled:"toggleButtonDisabled_aARS"};function H(e){let{className:t,buttonClassName:n,value:r,onChange:o}=e;const i=(0,B.A)(),s=(0,l.T)({message:"Switch between dark and light mode (currently {mode})",id:"theme.colorToggle.ariaLabel",description:"The ARIA label for the navbar color mode toggle"},{mode:"dark"===r?(0,l.T)({message:"dark mode",id:"theme.colorToggle.ariaLabel.mode.dark",description:"The name for the dark color mode"}):(0,l.T)({message:"light mode",id:"theme.colorToggle.ariaLabel.mode.light",description:"The name for the light color mode"})});return(0,u.jsx)("div",{className:(0,a.A)(U.toggle,t),children:(0,u.jsxs)("button",{className:(0,a.A)("clean-btn",U.toggleButton,!i&&U.toggleButtonDisabled,n),type:"button",onClick:()=>o("dark"===r?"light":"dark"),disabled:!i,title:s,"aria-label":s,"aria-live":"polite",children:[(0,u.jsx)(z,{className:(0,a.A)(U.toggleIcon,U.lightToggleIcon)}),(0,u.jsx)($,{className:(0,a.A)(U.toggleIcon,U.darkToggleIcon)})]})})}const V=r.memo(H),W={darkNavbarColorModeToggle:"darkNavbarColorModeToggle_X3D1"};function G(e){let{className:t}=e;const n=(0,w.p)().navbar.style,r=(0,w.p)().colorMode.disableSwitch,{colorMode:a,setColorMode:o}=(0,F.G)();return r?null:(0,u.jsx)(V,{className:t,buttonClassName:"dark"===n?W.darkNavbarColorModeToggle:void 0,value:a,onChange:o})}var q=n(23465);function K(){return(0,u.jsx)(q.A,{className:"navbar__brand",imageClassName:"navbar__logo",titleClassName:"navbar__title text--truncate"})}function Y(){const e=(0,N.M)();return(0,u.jsx)("button",{type:"button","aria-label":(0,l.T)({id:"theme.docs.sidebar.closeSidebarButtonAriaLabel",message:"Close navigation bar",description:"The ARIA label for close button of mobile sidebar"}),className:"clean-btn navbar-sidebar__close",onClick:()=>e.toggle(),children:(0,u.jsx)(x,{color:"var(--ifm-color-emphasis-600)"})})}function Q(){return(0,u.jsxs)("div",{className:"navbar-sidebar__brand",children:[(0,u.jsx)(K,{}),(0,u.jsx)(G,{className:"margin-right--md"}),(0,u.jsx)(Y,{})]})}var Z=n(28774),X=n(86025),J=n(16654),ee=n(91252),te=n(43186);function ne(e){let{activeBasePath:t,activeBaseRegex:n,to:r,href:a,label:o,html:i,isDropdownLink:s,prependBaseUrlToHref:l,...c}=e;const d=(0,X.A)(r),p=(0,X.A)(t),f=(0,X.A)(a,{forcePrependBaseUrl:!0}),h=o&&a&&!(0,J.A)(a),g=i?{dangerouslySetInnerHTML:{__html:i}}:{children:(0,u.jsxs)(u.Fragment,{children:[o,h&&(0,u.jsx)(te.A,{...s&&{width:12,height:12}})]})};return a?(0,u.jsx)(Z.A,{href:l?f:a,...c,...g}):(0,u.jsx)(Z.A,{to:d,isNavLink:!0,...(t||n)&&{isActive:(e,t)=>n?(0,ee.G)(n,t.pathname):t.pathname.startsWith(p)},...c,...g})}function re(e){let{className:t,isDropdownItem:n=!1,...r}=e;const o=(0,u.jsx)(ne,{className:(0,a.A)(n?"dropdown__link":"navbar__item navbar__link",t),isDropdownLink:n,...r});return n?(0,u.jsx)("li",{children:o}):o}function ae(e){let{className:t,isDropdownItem:n,...r}=e;return(0,u.jsx)("li",{className:"menu__list-item",children:(0,u.jsx)(ne,{className:(0,a.A)("menu__link",t),...r})})}function oe(e){let{mobile:t=!1,position:n,...r}=e;const a=t?ae:re;return(0,u.jsx)(a,{...r,activeClassName:r.activeClassName??(t?"menu__link--active":"navbar__link--active")})}var ie=n(41422),se=n(99169),le=n(44586);const ce={dropdownNavbarItemMobile:"dropdownNavbarItemMobile_S0Fm"};function ue(e,t){return e.some((e=>function(e,t){return!!(0,se.ys)(e.to,t)||!!(0,ee.G)(e.activeBaseRegex,t)||!(!e.activeBasePath||!t.startsWith(e.activeBasePath))}(e,t)))}function de(e){let{items:t,position:n,className:o,onClick:i,...s}=e;const l=(0,r.useRef)(null),[c,d]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("focusin",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("focusin",e)}}),[l]),(0,u.jsxs)("div",{ref:l,className:(0,a.A)("navbar__item","dropdown","dropdown--hoverable",{"dropdown--right":"right"===n,"dropdown--show":c}),children:[(0,u.jsx)(ne,{"aria-haspopup":"true","aria-expanded":c,role:"button",href:s.to?void 0:"#",className:(0,a.A)("navbar__link",o),...s,onClick:s.to?void 0:e=>e.preventDefault(),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d(!c))},children:s.children??s.label}),(0,u.jsx)("ul",{className:"dropdown__menu",children:t.map(((e,t)=>(0,r.createElement)(We,{isDropdownItem:!0,activeClassName:"dropdown__link--active",...e,key:t})))})]})}function pe(e){let{items:t,className:n,position:o,onClick:i,...l}=e;const c=function(){const{siteConfig:{baseUrl:e}}=(0,le.A)(),{pathname:t}=(0,s.zy)();return t.replace(e,"/")}(),d=ue(t,c),{collapsed:p,toggleCollapsed:f,setCollapsed:h}=(0,ie.u)({initialState:()=>!d});return(0,r.useEffect)((()=>{d&&h(!d)}),[c,d,h]),(0,u.jsxs)("li",{className:(0,a.A)("menu__list-item",{"menu__list-item--collapsed":p}),children:[(0,u.jsx)(ne,{role:"button",className:(0,a.A)(ce.dropdownNavbarItemMobile,"menu__link menu__link--sublist menu__link--sublist-caret",n),...l,onClick:e=>{e.preventDefault(),f()},children:l.children??l.label}),(0,u.jsx)(ie.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:p,children:t.map(((e,t)=>(0,r.createElement)(We,{mobile:!0,isDropdownItem:!0,onClick:i,activeClassName:"menu__link--active",...e,key:t})))})]})}function fe(e){let{mobile:t=!1,...n}=e;const r=t?pe:de;return(0,u.jsx)(r,{...n})}var he=n(32131);function ge(e){let{width:t=20,height:n=20,...r}=e;return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:n,"aria-hidden":!0,...r,children:(0,u.jsx)("path",{fill:"currentColor",d:"M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"})})}const me="iconLanguage_nlXk";var be=n(40961);function ye(){return r.createElement("svg",{width:"15",height:"15",className:"DocSearch-Control-Key-Icon"},r.createElement("path",{d:"M4.505 4.496h2M5.505 5.496v5M8.216 4.496l.055 5.993M10 7.5c.333.333.5.667.5 1v2M12.326 4.5v5.996M8.384 4.496c1.674 0 2.116 0 2.116 1.5s-.442 1.5-2.116 1.5M3.205 9.303c-.09.448-.277 1.21-1.241 1.203C1 10.5.5 9.513.5 8V7c0-1.57.5-2.5 1.464-2.494.964.006 1.134.598 1.24 1.342M12.553 10.5h1.953",strokeWidth:"1.2",stroke:"currentColor",fill:"none",strokeLinecap:"square"}))}var ve=n(89188),we=["translations"];function ke(){return ke=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Ee="Ctrl";var Ce=r.forwardRef((function(e,t){var n=e.translations,a=void 0===n?{}:n,o=_e(e,we),i=a.buttonText,s=void 0===i?"Search":i,l=a.buttonAriaLabel,c=void 0===l?"Search":l,u=xe((0,r.useState)(null),2),d=u[0],p=u[1];return(0,r.useEffect)((function(){"undefined"!=typeof navigator&&(/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?p("\u2318"):p(Ee))}),[]),r.createElement("button",ke({type:"button",className:"DocSearch DocSearch-Button","aria-label":c},o,{ref:t}),r.createElement("span",{className:"DocSearch-Button-Container"},r.createElement(ve.W,null),r.createElement("span",{className:"DocSearch-Button-Placeholder"},s)),r.createElement("span",{className:"DocSearch-Button-Keys"},null!==d&&r.createElement(r.Fragment,null,r.createElement(Te,{reactsToKey:d===Ee?Ee:"Meta"},d===Ee?r.createElement(ye,null):d),r.createElement(Te,{reactsToKey:"k"},"K"))))}));function Te(e){var t=e.reactsToKey,n=e.children,a=xe((0,r.useState)(!1),2),o=a[0],i=a[1];return(0,r.useEffect)((function(){if(t)return window.addEventListener("keydown",e),window.addEventListener("keyup",n),function(){window.removeEventListener("keydown",e),window.removeEventListener("keyup",n)};function e(e){e.key===t&&i(!0)}function n(e){e.key!==t&&"Meta"!==e.key||i(!1)}}),[t]),r.createElement("kbd",{className:o?"DocSearch-Button-Key DocSearch-Button-Key--pressed":"DocSearch-Button-Key"},n)}var Ae=n(5260),Ne=n(24255),Le=n(51062),Pe=n(2967);const Re={button:{buttonText:(0,l.T)({id:"theme.SearchBar.label",message:"Search",description:"The ARIA label and placeholder for search button"}),buttonAriaLabel:(0,l.T)({id:"theme.SearchBar.label",message:"Search",description:"The ARIA label and placeholder for search button"})},modal:{searchBox:{resetButtonTitle:(0,l.T)({id:"theme.SearchModal.searchBox.resetButtonTitle",message:"Clear the query",description:"The label and ARIA label for search box reset button"}),resetButtonAriaLabel:(0,l.T)({id:"theme.SearchModal.searchBox.resetButtonTitle",message:"Clear the query",description:"The label and ARIA label for search box reset button"}),cancelButtonText:(0,l.T)({id:"theme.SearchModal.searchBox.cancelButtonText",message:"Cancel",description:"The label and ARIA label for search box cancel button"}),cancelButtonAriaLabel:(0,l.T)({id:"theme.SearchModal.searchBox.cancelButtonText",message:"Cancel",description:"The label and ARIA label for search box cancel button"})},startScreen:{recentSearchesTitle:(0,l.T)({id:"theme.SearchModal.startScreen.recentSearchesTitle",message:"Recent",description:"The title for recent searches"}),noRecentSearchesText:(0,l.T)({id:"theme.SearchModal.startScreen.noRecentSearchesText",message:"No recent searches",description:"The text when no recent searches"}),saveRecentSearchButtonTitle:(0,l.T)({id:"theme.SearchModal.startScreen.saveRecentSearchButtonTitle",message:"Save this search",description:"The label for save recent search button"}),removeRecentSearchButtonTitle:(0,l.T)({id:"theme.SearchModal.startScreen.removeRecentSearchButtonTitle",message:"Remove this search from history",description:"The label for remove recent search button"}),favoriteSearchesTitle:(0,l.T)({id:"theme.SearchModal.startScreen.favoriteSearchesTitle",message:"Favorite",description:"The title for favorite searches"}),removeFavoriteSearchButtonTitle:(0,l.T)({id:"theme.SearchModal.startScreen.removeFavoriteSearchButtonTitle",message:"Remove this search from favorites",description:"The label for remove favorite search button"})},errorScreen:{titleText:(0,l.T)({id:"theme.SearchModal.errorScreen.titleText",message:"Unable to fetch results",description:"The title for error screen of search modal"}),helpText:(0,l.T)({id:"theme.SearchModal.errorScreen.helpText",message:"You might want to check your network connection.",description:"The help text for error screen of search modal"})},footer:{selectText:(0,l.T)({id:"theme.SearchModal.footer.selectText",message:"to select",description:"The explanatory text of the action for the enter key"}),selectKeyAriaLabel:(0,l.T)({id:"theme.SearchModal.footer.selectKeyAriaLabel",message:"Enter key",description:"The ARIA label for the Enter key button that makes the selection"}),navigateText:(0,l.T)({id:"theme.SearchModal.footer.navigateText",message:"to navigate",description:"The explanatory text of the action for the Arrow up and Arrow down key"}),navigateUpKeyAriaLabel:(0,l.T)({id:"theme.SearchModal.footer.navigateUpKeyAriaLabel",message:"Arrow up",description:"The ARIA label for the Arrow up key button that makes the navigation"}),navigateDownKeyAriaLabel:(0,l.T)({id:"theme.SearchModal.footer.navigateDownKeyAriaLabel",message:"Arrow down",description:"The ARIA label for the Arrow down key button that makes the navigation"}),closeText:(0,l.T)({id:"theme.SearchModal.footer.closeText",message:"to close",description:"The explanatory text of the action for Escape key"}),closeKeyAriaLabel:(0,l.T)({id:"theme.SearchModal.footer.closeKeyAriaLabel",message:"Escape key",description:"The ARIA label for the Escape key button that close the modal"}),searchByText:(0,l.T)({id:"theme.SearchModal.footer.searchByText",message:"Search by",description:"The text explain that the search is making by Algolia"})},noResultsScreen:{noResultsText:(0,l.T)({id:"theme.SearchModal.noResultsScreen.noResultsText",message:"No results for",description:"The text explains that there are no results for the following search"}),suggestedQueryText:(0,l.T)({id:"theme.SearchModal.noResultsScreen.suggestedQueryText",message:"Try searching for",description:"The text for the suggested query when no results are found for the following search"}),reportMissingResultsText:(0,l.T)({id:"theme.SearchModal.noResultsScreen.reportMissingResultsText",message:"Believe this query should return results?",description:"The text for the question where the user thinks there are missing results"}),reportMissingResultsLinkText:(0,l.T)({id:"theme.SearchModal.noResultsScreen.reportMissingResultsLinkText",message:"Let us know.",description:"The text for the link to report missing results"})}},placeholder:(0,l.T)({id:"theme.SearchModal.placeholder",message:"Search docs",description:"The placeholder of the input of the DocSearch pop-up modal"})};let Oe=null;function je(e){let{hit:t,children:n}=e;return(0,u.jsx)(Z.A,{to:t.url,children:n})}function Ie(e){let{state:t,onClose:n}=e;const r=(0,Ne.w)();return(0,u.jsx)(Z.A,{to:r(t.query),onClick:n,children:(0,u.jsx)(l.A,{id:"theme.SearchBar.seeAll",values:{count:t.context.nbHits},children:"See all {count} results"})})}function De(e){let{contextualSearch:t,externalUrlRegex:a,...o}=e;const{siteMetadata:i}=(0,le.A)(),l=(0,Le.C)(),c=function(){const{locale:e,tags:t}=(0,Pe.af)();return[`language:${e}`,t.map((e=>`docusaurus_tag:${e}`))]}(),d=o.searchParameters?.facetFilters??[],p=t?function(e,t){const n=e=>"string"==typeof e?[e]:e;return[...n(e),...n(t)]}(c,d):d,f={...o.searchParameters,facetFilters:p},h=(0,s.W6)(),g=(0,r.useRef)(null),m=(0,r.useRef)(null),[b,y]=(0,r.useState)(!1),[v,w]=(0,r.useState)(void 0),k=(0,r.useCallback)((()=>Oe?Promise.resolve():Promise.all([n.e(9462).then(n.bind(n,9462)),Promise.all([n.e(1869),n.e(8913)]).then(n.bind(n,58913)),Promise.all([n.e(1869),n.e(416)]).then(n.bind(n,90416))]).then((e=>{let[{DocSearchModal:t}]=e;Oe=t}))),[]),x=(0,r.useCallback)((()=>{k().then((()=>{g.current=document.createElement("div"),document.body.insertBefore(g.current,document.body.firstChild),y(!0)}))}),[k,y]),S=(0,r.useCallback)((()=>{y(!1),g.current?.remove(),m.current?.focus()}),[y]),_=(0,r.useCallback)((e=>{k().then((()=>{y(!0),w(e.key)}))}),[k,y,w]),E=(0,r.useRef)({navigate(e){let{itemUrl:t}=e;(0,ee.G)(a,t)?window.location.href=t:h.push(t)}}).current,C=(0,r.useRef)((e=>o.transformItems?o.transformItems(e):e.map((e=>({...e,url:l(e.url)}))))).current,T=(0,r.useMemo)((()=>e=>(0,u.jsx)(Ie,{...e,onClose:S})),[S]),A=(0,r.useCallback)((e=>(e.addAlgoliaAgent("docusaurus",i.docusaurusVersion),e)),[i.docusaurusVersion]);return function(e){var t=e.isOpen,n=e.onOpen,a=e.onClose,o=e.onInput,i=e.searchButtonRef;r.useEffect((function(){function e(e){var r;(27===e.keyCode&&t||"k"===(null===(r=e.key)||void 0===r?void 0:r.toLowerCase())&&(e.metaKey||e.ctrlKey)||!function(e){var t=e.target,n=t.tagName;return t.isContentEditable||"INPUT"===n||"SELECT"===n||"TEXTAREA"===n}(e)&&"/"===e.key&&!t)&&(e.preventDefault(),t?a():document.body.classList.contains("DocSearch--active")||document.body.classList.contains("DocSearch--active")||n()),i&&i.current===document.activeElement&&o&&/[a-zA-Z0-9]/.test(String.fromCharCode(e.keyCode))&&o(e)}return window.addEventListener("keydown",e),function(){window.removeEventListener("keydown",e)}}),[t,n,a,o,i])}({isOpen:b,onOpen:x,onClose:S,onInput:_,searchButtonRef:m}),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Ae.A,{children:(0,u.jsx)("link",{rel:"preconnect",href:`https://${o.appId}-dsn.algolia.net`,crossOrigin:"anonymous"})}),(0,u.jsx)(Ce,{onTouchStart:k,onFocus:k,onMouseOver:k,onClick:x,ref:m,translations:Re.button}),b&&Oe&&g.current&&(0,be.createPortal)((0,u.jsx)(Oe,{onClose:S,initialScrollY:window.scrollY,initialQuery:v,navigator:E,transformItems:C,hitComponent:je,transformSearchClient:A,...o.searchPagePath&&{resultsFooterComponent:T},...o,searchParameters:f,placeholder:Re.placeholder,translations:Re.modal}),g.current)]})}function Me(){const{siteConfig:e}=(0,le.A)();return(0,u.jsx)(De,{...e.themeConfig.algolia})}const Fe={navbarSearchContainer:"navbarSearchContainer_Bca1"};function Be(e){let{children:t,className:n}=e;return(0,u.jsx)("div",{className:(0,a.A)(n,Fe.navbarSearchContainer),children:t})}var ze=n(44070),$e=n(84142);var Ue=n(55597);const He=e=>e.docs.find((t=>t.id===e.mainDocId));const Ve={default:oe,localeDropdown:function(e){let{mobile:t,dropdownItemsBefore:n,dropdownItemsAfter:r,queryString:a="",...o}=e;const{i18n:{currentLocale:i,locales:c,localeConfigs:d}}=(0,le.A)(),p=(0,he.o)(),{search:f,hash:h}=(0,s.zy)(),g=[...n,...c.map((e=>{const n=`${`pathname://${p.createUrl({locale:e,fullyQualified:!1})}`}${f}${h}${a}`;return{label:d[e].label,lang:d[e].htmlLang,to:n,target:"_self",autoAddBaseUrl:!1,className:e===i?t?"menu__link--active":"dropdown__link--active":""}})),...r],m=t?(0,l.T)({message:"Languages",id:"theme.navbar.mobileLanguageDropdown.label",description:"The label for the mobile language switcher dropdown"}):d[i].label;return(0,u.jsx)(fe,{...o,mobile:t,label:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ge,{className:me}),m]}),items:g})},search:function(e){let{mobile:t,className:n}=e;return t?null:(0,u.jsx)(Be,{className:n,children:(0,u.jsx)(Me,{})})},dropdown:fe,html:function(e){let{value:t,className:n,mobile:r=!1,isDropdownItem:o=!1}=e;const i=o?"li":"div";return(0,u.jsx)(i,{className:(0,a.A)({navbar__item:!r&&!o,"menu__list-item":r},n),dangerouslySetInnerHTML:{__html:t}})},doc:function(e){let{docId:t,label:n,docsPluginId:r,...a}=e;const{activeDoc:o}=(0,ze.zK)(r),i=(0,$e.QB)(t,r),s=o?.path===i?.path;return null===i||i.unlisted&&!s?null:(0,u.jsx)(oe,{exact:!0,...a,isActive:()=>s||!!o?.sidebar&&o.sidebar===i.sidebar,label:n??i.id,to:i.path})},docSidebar:function(e){let{sidebarId:t,label:n,docsPluginId:r,...a}=e;const{activeDoc:o}=(0,ze.zK)(r),i=(0,$e.fW)(t,r).link;if(!i)throw new Error(`DocSidebarNavbarItem: Sidebar with ID "${t}" doesn't have anything to be linked to.`);return(0,u.jsx)(oe,{exact:!0,...a,isActive:()=>o?.sidebar===t,label:n??i.label,to:i.path})},docsVersion:function(e){let{label:t,to:n,docsPluginId:r,...a}=e;const o=(0,$e.Vd)(r)[0],i=t??o.label,s=n??(e=>e.docs.find((t=>t.id===e.mainDocId)))(o).path;return(0,u.jsx)(oe,{...a,label:i,to:s})},docsVersionDropdown:function(e){let{mobile:t,docsPluginId:n,dropdownActiveClassDisabled:r,dropdownItemsBefore:a,dropdownItemsAfter:o,...i}=e;const{search:c,hash:d}=(0,s.zy)(),p=(0,ze.zK)(n),f=(0,ze.jh)(n),{savePreferredVersionName:h}=(0,Ue.g1)(n),g=[...a,...f.map((e=>{const t=p.alternateDocVersions[e.name]??He(e);return{label:e.label,to:`${t.path}${c}${d}`,isActive:()=>e===p.activeVersion,onClick:()=>h(e.name)}})),...o],m=(0,$e.Vd)(n)[0],b=t&&g.length>1?(0,l.T)({id:"theme.navbar.mobileVersionsDropdown.label",message:"Versions",description:"The label for the navbar versions dropdown on mobile view"}):m.label,y=t&&g.length>1?void 0:He(m).path;return g.length<=1?(0,u.jsx)(oe,{...i,mobile:t,label:b,to:y,isActive:r?()=>!1:void 0}):(0,u.jsx)(fe,{...i,mobile:t,label:b,to:y,items:g,isActive:r?()=>!1:void 0})}};function We(e){let{type:t,...n}=e;const r=function(e,t){return e&&"default"!==e?e:"items"in t?"dropdown":"default"}(t,n),a=Ve[r];if(!a)throw new Error(`No NavbarItem component found for type "${t}".`);return(0,u.jsx)(a,{...n})}function Ge(){const e=(0,N.M)(),t=(0,w.p)().navbar.items;return(0,u.jsx)("ul",{className:"menu__list",children:t.map(((t,n)=>(0,r.createElement)(We,{mobile:!0,...t,onClick:()=>e.toggle(),key:n})))})}function qe(e){return(0,u.jsx)("button",{...e,type:"button",className:"clean-btn navbar-sidebar__back",children:(0,u.jsx)(l.A,{id:"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel",description:"The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)",children:"\u2190 Back to main menu"})})}function Ke(){const e=0===(0,w.p)().navbar.items.length,t=D();return(0,u.jsxs)(u.Fragment,{children:[!e&&(0,u.jsx)(qe,{onClick:()=>t.hide()}),t.content]})}function Ye(){const e=(0,N.M)();var t;return void 0===(t=e.shown)&&(t=!0),(0,r.useEffect)((()=>(document.body.style.overflow=t?"hidden":"visible",()=>{document.body.style.overflow="visible"})),[t]),e.shouldRender?(0,u.jsx)(M,{header:(0,u.jsx)(Q,{}),primaryMenu:(0,u.jsx)(Ge,{}),secondaryMenu:(0,u.jsx)(Ke,{})}):null}const Qe={navbarHideable:"navbarHideable_m1mJ",navbarHidden:"navbarHidden_jGov"};function Ze(e){return(0,u.jsx)("div",{role:"presentation",...e,className:(0,a.A)("navbar-sidebar__backdrop",e.className)})}function Xe(e){let{children:t}=e;const{navbar:{hideOnScroll:n,style:o}}=(0,w.p)(),i=(0,N.M)(),{navbarRef:s,isNavbarVisible:d}=function(e){const[t,n]=(0,r.useState)(e),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),i=(0,r.useCallback)((e=>{null!==e&&(o.current=e.getBoundingClientRect().height)}),[]);return(0,L.Mq)(((t,r)=>{let{scrollY:i}=t;if(!e)return;if(i=s?n(!1):i+c{if(!e)return;const r=t.location.hash;if(r?document.getElementById(r.substring(1)):void 0)return a.current=!0,void n(!1);n(!0)})),{navbarRef:i,isNavbarVisible:t}}(n);return(0,u.jsxs)("nav",{ref:s,"aria-label":(0,l.T)({id:"theme.NavBar.navAriaLabel",message:"Main",description:"The ARIA label for the main navigation"}),className:(0,a.A)("navbar","navbar--fixed-top",n&&[Qe.navbarHideable,!d&&Qe.navbarHidden],{"navbar--dark":"dark"===o,"navbar--primary":"primary"===o,"navbar-sidebar--show":i.shown}),children:[t,(0,u.jsx)(Ze,{onClick:i.toggle}),(0,u.jsx)(Ye,{})]})}var Je=n(12181);const et="right";function tt(e){let{width:t=30,height:n=30,className:r,...a}=e;return(0,u.jsx)("svg",{className:r,width:t,height:n,viewBox:"0 0 30 30","aria-hidden":"true",...a,children:(0,u.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M4 7h22M4 15h22M4 23h22"})})}function nt(){const{toggle:e,shown:t}=(0,N.M)();return(0,u.jsx)("button",{onClick:e,"aria-label":(0,l.T)({id:"theme.docs.sidebar.toggleSidebarButtonAriaLabel",message:"Toggle navigation bar",description:"The ARIA label for hamburger menu button of mobile navigation"}),"aria-expanded":t,className:"navbar__toggle clean-btn",type:"button",children:(0,u.jsx)(tt,{})})}const rt={colorModeToggle:"colorModeToggle_DEke"};function at(e){let{items:t}=e;return(0,u.jsx)(u.Fragment,{children:t.map(((e,t)=>(0,u.jsx)(Je.k2,{onError:t=>new Error(`A theme navbar item failed to render.\nPlease double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:\n${JSON.stringify(e,null,2)}`,{cause:t}),children:(0,u.jsx)(We,{...e})},t)))})}function ot(e){let{left:t,right:n}=e;return(0,u.jsxs)("div",{className:"navbar__inner",children:[(0,u.jsx)("div",{className:"navbar__items",children:t}),(0,u.jsx)("div",{className:"navbar__items navbar__items--right",children:n})]})}function it(){const e=(0,N.M)(),t=(0,w.p)().navbar.items,[n,r]=function(e){function t(e){return"left"===(e.position??et)}return[e.filter(t),e.filter((e=>!t(e)))]}(t),a=t.find((e=>"search"===e.type));return(0,u.jsx)(ot,{left:(0,u.jsxs)(u.Fragment,{children:[!e.disabled&&(0,u.jsx)(nt,{}),(0,u.jsx)(K,{}),(0,u.jsx)(at,{items:n})]}),right:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(at,{items:r}),(0,u.jsx)(G,{className:rt.colorModeToggle}),!a&&(0,u.jsx)(Be,{children:(0,u.jsx)(Me,{})})]})})}function st(){return(0,u.jsx)(Xe,{children:(0,u.jsx)(it,{})})}function lt(e){let{item:t}=e;const{to:n,href:r,label:a,prependBaseUrlToHref:o,...i}=t,s=(0,X.A)(n),l=(0,X.A)(r,{forcePrependBaseUrl:!0});return(0,u.jsxs)(Z.A,{className:"footer__link-item",...r?{href:o?l:r}:{to:s},...i,children:[a,r&&!(0,J.A)(r)&&(0,u.jsx)(te.A,{})]})}function ct(e){let{item:t}=e;return t.html?(0,u.jsx)("li",{className:"footer__item",dangerouslySetInnerHTML:{__html:t.html}}):(0,u.jsx)("li",{className:"footer__item",children:(0,u.jsx)(lt,{item:t})},t.href??t.to)}function ut(e){let{column:t}=e;return(0,u.jsxs)("div",{className:"col footer__col",children:[(0,u.jsx)("div",{className:"footer__title",children:t.title}),(0,u.jsx)("ul",{className:"footer__items clean-list",children:t.items.map(((e,t)=>(0,u.jsx)(ct,{item:e},t)))})]})}function dt(e){let{columns:t}=e;return(0,u.jsx)("div",{className:"row footer__links",children:t.map(((e,t)=>(0,u.jsx)(ut,{column:e},t)))})}function pt(){return(0,u.jsx)("span",{className:"footer__link-separator",children:"\xb7"})}function ft(e){let{item:t}=e;return t.html?(0,u.jsx)("span",{className:"footer__link-item",dangerouslySetInnerHTML:{__html:t.html}}):(0,u.jsx)(lt,{item:t})}function ht(e){let{links:t}=e;return(0,u.jsx)("div",{className:"footer__links text--center",children:(0,u.jsx)("div",{className:"footer__links",children:t.map(((e,n)=>(0,u.jsxs)(r.Fragment,{children:[(0,u.jsx)(ft,{item:e}),t.length!==n+1&&(0,u.jsx)(pt,{})]},n)))})})}function gt(e){let{links:t}=e;return function(e){return"title"in e[0]}(t)?(0,u.jsx)(dt,{columns:t}):(0,u.jsx)(ht,{links:t})}var mt=n(21122);const bt={footerLogoLink:"footerLogoLink_BH7S"};function yt(e){let{logo:t}=e;const{withBaseUrl:n}=(0,X.h)(),r={light:n(t.src),dark:n(t.srcDark??t.src)};return(0,u.jsx)(mt.A,{className:(0,a.A)("footer__logo",t.className),alt:t.alt,sources:r,width:t.width,height:t.height,style:t.style})}function vt(e){let{logo:t}=e;return t.href?(0,u.jsx)(Z.A,{href:t.href,className:bt.footerLogoLink,target:t.target,children:(0,u.jsx)(yt,{logo:t})}):(0,u.jsx)(yt,{logo:t})}function wt(e){let{copyright:t}=e;return(0,u.jsx)("div",{className:"footer__copyright",dangerouslySetInnerHTML:{__html:t}})}function kt(e){let{style:t,links:n,logo:r,copyright:o}=e;return(0,u.jsx)("footer",{className:(0,a.A)("footer",{"footer--dark":"dark"===t}),children:(0,u.jsxs)("div",{className:"container container-fluid",children:[n,(r||o)&&(0,u.jsxs)("div",{className:"footer__bottom text--center",children:[r&&(0,u.jsx)("div",{className:"margin-bottom--sm",children:r}),o]})]})})}function xt(){const{footer:e}=(0,w.p)();if(!e)return null;const{copyright:t,links:n,logo:r,style:a}=e;return(0,u.jsx)(kt,{style:a,links:n&&n.length>0&&(0,u.jsx)(gt,{links:n}),logo:r&&(0,u.jsx)(vt,{logo:r}),copyright:t&&(0,u.jsx)(wt,{copyright:t})})}const St=r.memo(xt),_t=(0,P.fM)([F.a,k.oq,L.Tv,Ue.VQ,i.Jx,function(e){let{children:t}=e;return(0,u.jsx)(R.y_,{children:(0,u.jsx)(N.e,{children:(0,u.jsx)(j,{children:t})})})}]);function Et(e){let{children:t}=e;return(0,u.jsx)(_t,{children:t})}var Ct=n(51107);function Tt(e){let{error:t,tryAgain:n}=e;return(0,u.jsx)("main",{className:"container margin-vert--xl",children:(0,u.jsx)("div",{className:"row",children:(0,u.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,u.jsx)(Ct.A,{as:"h1",className:"hero__title",children:(0,u.jsx)(l.A,{id:"theme.ErrorPageContent.title",description:"The title of the fallback page when the page crashed",children:"This page crashed."})}),(0,u.jsx)("div",{className:"margin-vert--lg",children:(0,u.jsx)(Je.a2,{onClick:n,className:"button button--primary shadow--lw"})}),(0,u.jsx)("hr",{}),(0,u.jsx)("div",{className:"margin-vert--md",children:(0,u.jsx)(Je.bq,{error:t})})]})})})}const At={mainWrapper:"mainWrapper_z2l0"};function Nt(e){const{children:t,noFooter:n,wrapperClassName:r,title:s,description:l}=e;return(0,b.J)(),(0,u.jsxs)(Et,{children:[(0,u.jsx)(i.be,{title:s,description:l}),(0,u.jsx)(v,{}),(0,u.jsx)(A,{}),(0,u.jsx)(st,{}),(0,u.jsx)("div",{id:d,className:(0,a.A)(m.G.wrapper.main,At.mainWrapper,r),children:(0,u.jsx)(o.A,{fallback:e=>(0,u.jsx)(Tt,{...e}),children:t})}),!n&&(0,u.jsx)(St,{})]})}},23465:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});n(96540);var r=n(28774),a=n(86025),o=n(44586),i=n(6342),s=n(21122),l=n(74848);function c(e){let{logo:t,alt:n,imageClassName:r}=e;const o={light:(0,a.A)(t.src),dark:(0,a.A)(t.srcDark||t.src)},i=(0,l.jsx)(s.A,{className:t.className,sources:o,height:t.height,width:t.width,alt:n,style:t.style});return r?(0,l.jsx)("div",{className:r,children:i}):i}function u(e){const{siteConfig:{title:t}}=(0,o.A)(),{navbar:{title:n,logo:s}}=(0,i.p)(),{imageClassName:u,titleClassName:d,...p}=e,f=(0,a.A)(s?.href||"/"),h=n?"":t,g=s?.alt??h;return(0,l.jsxs)(r.A,{to:f,...p,...s?.target&&{target:s.target},children:[s&&(0,l.jsx)(c,{logo:s,alt:g,imageClassName:u}),null!=n&&(0,l.jsx)("b",{className:d,children:n})]})}},41463:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(96540);var r=n(5260),a=n(74848);function o(e){let{locale:t,version:n,tag:o}=e;const i=t;return(0,a.jsxs)(r.A,{children:[t&&(0,a.jsx)("meta",{name:"docusaurus_locale",content:t}),n&&(0,a.jsx)("meta",{name:"docusaurus_version",content:n}),o&&(0,a.jsx)("meta",{name:"docusaurus_tag",content:o}),i&&(0,a.jsx)("meta",{name:"docsearch:language",content:i}),n&&(0,a.jsx)("meta",{name:"docsearch:version",content:n}),o&&(0,a.jsx)("meta",{name:"docsearch:docusaurus_tag",content:o})]})}},21122:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(96540),a=n(15066),o=n(92303),i=n(95293);const s={themedComponent:"themedComponent_mlkZ","themedComponent--light":"themedComponent--light_NVdE","themedComponent--dark":"themedComponent--dark_xIcU"};var l=n(74848);function c(e){let{className:t,children:n}=e;const c=(0,o.A)(),{colorMode:u}=(0,i.G)();return(0,l.jsx)(l.Fragment,{children:(c?"dark"===u?["dark"]:["light"]:["light","dark"]).map((e=>{const o=n({theme:e,className:(0,a.A)(t,s.themedComponent,s[`themedComponent--${e}`])});return(0,l.jsx)(r.Fragment,{children:o},e)}))})}function u(e){const{sources:t,className:n,alt:r,...a}=e;return(0,l.jsx)(c,{className:n,children:e=>{let{theme:n,className:o}=e;return(0,l.jsx)("img",{src:t[n],alt:r,className:o,...a})}})}},41422:(e,t,n)=>{"use strict";n.d(t,{N:()=>b,u:()=>c});var r=n(96540),a=n(38193),o=n(205),i=n(53109),s=n(74848);const l="ease-in-out";function c(e){let{initialState:t}=e;const[n,a]=(0,r.useState)(t??!1),o=(0,r.useCallback)((()=>{a((e=>!e))}),[]);return{collapsed:n,setCollapsed:a,toggleCollapsed:o}}const u={display:"none",overflow:"hidden",height:"0px"},d={display:"block",overflow:"visible",height:"auto"};function p(e,t){const n=t?u:d;e.style.display=n.display,e.style.overflow=n.overflow,e.style.height=n.height}function f(e){let{collapsibleRef:t,collapsed:n,animation:a}=e;const o=(0,r.useRef)(!1);(0,r.useEffect)((()=>{const e=t.current;function r(){const t=e.scrollHeight,n=a?.duration??function(e){if((0,i.O)())return 1;const t=e/36;return Math.round(10*(4+15*t**.25+t/5))}(t);return{transition:`height ${n}ms ${a?.easing??l}`,height:`${t}px`}}function s(){const t=r();e.style.transition=t.transition,e.style.height=t.height}if(!o.current)return p(e,n),void(o.current=!0);return e.style.willChange="height",function(){const t=requestAnimationFrame((()=>{n?(s(),requestAnimationFrame((()=>{e.style.height=u.height,e.style.overflow=u.overflow}))):(e.style.display="block",requestAnimationFrame((()=>{s()})))}));return()=>cancelAnimationFrame(t)}()}),[t,n,a])}function h(e){if(!a.A.canUseDOM)return e?u:d}function g(e){let{as:t="div",collapsed:n,children:a,animation:o,onCollapseTransitionEnd:i,className:l,disableSSRStyle:c}=e;const u=(0,r.useRef)(null);return f({collapsibleRef:u,collapsed:n,animation:o}),(0,s.jsx)(t,{ref:u,style:c?void 0:h(n),onTransitionEnd:e=>{"height"===e.propertyName&&(p(u.current,n),i?.(n))},className:l,children:a})}function m(e){let{collapsed:t,...n}=e;const[a,i]=(0,r.useState)(!t),[l,c]=(0,r.useState)(t);return(0,o.A)((()=>{t||i(!0)}),[t]),(0,o.A)((()=>{a&&c(t)}),[a,t]),a?(0,s.jsx)(g,{...n,collapsed:l}):null}function b(e){let{lazy:t,...n}=e;const r=t?m:g;return(0,s.jsx)(r,{...n})}},65041:(e,t,n)=>{"use strict";n.d(t,{Mj:()=>g,oq:()=>h});var r=n(96540),a=n(92303),o=n(89466),i=n(89532),s=n(6342),l=n(74848);const c=(0,o.Wf)("docusaurus.announcement.dismiss"),u=(0,o.Wf)("docusaurus.announcement.id"),d=()=>"true"===c.get(),p=e=>c.set(String(e)),f=r.createContext(null);function h(e){let{children:t}=e;const n=function(){const{announcementBar:e}=(0,s.p)(),t=(0,a.A)(),[n,o]=(0,r.useState)((()=>!!t&&d()));(0,r.useEffect)((()=>{o(d())}),[]);const i=(0,r.useCallback)((()=>{p(!0),o(!0)}),[]);return(0,r.useEffect)((()=>{if(!e)return;const{id:t}=e;let n=u.get();"annoucement-bar"===n&&(n="announcement-bar");const r=t!==n;u.set(t),r&&p(!1),!r&&d()||o(!1)}),[e]),(0,r.useMemo)((()=>({isActive:!!e&&!n,close:i})),[e,n,i])}();return(0,l.jsx)(f.Provider,{value:n,children:t})}function g(){const e=(0,r.useContext)(f);if(!e)throw new i.dV("AnnouncementBarProvider");return e}},95293:(e,t,n)=>{"use strict";n.d(t,{G:()=>b,a:()=>m});var r=n(96540),a=n(38193),o=n(89532),i=n(89466),s=n(6342),l=n(74848);const c=r.createContext(void 0),u="theme",d=(0,i.Wf)(u),p={light:"light",dark:"dark"},f=e=>e===p.dark?p.dark:p.light,h=e=>a.A.canUseDOM?f(document.documentElement.getAttribute("data-theme")):f(e),g=e=>{d.set(f(e))};function m(e){let{children:t}=e;const n=function(){const{colorMode:{defaultMode:e,disableSwitch:t,respectPrefersColorScheme:n}}=(0,s.p)(),[a,o]=(0,r.useState)(h(e));(0,r.useEffect)((()=>{t&&d.del()}),[t]);const i=(0,r.useCallback)((function(t,r){void 0===r&&(r={});const{persist:a=!0}=r;t?(o(t),a&&g(t)):(o(n?window.matchMedia("(prefers-color-scheme: dark)").matches?p.dark:p.light:e),d.del())}),[n,e]);(0,r.useEffect)((()=>{document.documentElement.setAttribute("data-theme",f(a))}),[a]),(0,r.useEffect)((()=>{if(t)return;const e=e=>{if(e.key!==u)return;const t=d.get();null!==t&&i(f(t))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)}),[t,i]);const l=(0,r.useRef)(!1);return(0,r.useEffect)((()=>{if(t&&!n)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{window.matchMedia("print").matches||l.current?l.current=window.matchMedia("print").matches:i(null)};return e.addListener(r),()=>e.removeListener(r)}),[i,t,n]),(0,r.useMemo)((()=>({colorMode:a,setColorMode:i,get isDarkTheme(){return a===p.dark},setLightTheme(){i(p.light)},setDarkTheme(){i(p.dark)}})),[a,i])}();return(0,l.jsx)(c.Provider,{value:n,children:t})}function b(){const e=(0,r.useContext)(c);if(null==e)throw new o.dV("ColorModeProvider","Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.");return e}},55597:(e,t,n)=>{"use strict";n.d(t,{VQ:()=>b,XK:()=>w,g1:()=>v});var r=n(96540),a=n(44070),o=n(17065),i=n(6342),s=n(84142),l=n(89532),c=n(89466),u=n(74848);const d=e=>`docs-preferred-version-${e}`,p={save:(e,t,n)=>{(0,c.Wf)(d(e),{persistence:t}).set(n)},read:(e,t)=>(0,c.Wf)(d(e),{persistence:t}).get(),clear:(e,t)=>{(0,c.Wf)(d(e),{persistence:t}).del()}},f=e=>Object.fromEntries(e.map((e=>[e,{preferredVersionName:null}])));const h=r.createContext(null);function g(){const e=(0,a.Gy)(),t=(0,i.p)().docs.versionPersistence,n=(0,r.useMemo)((()=>Object.keys(e)),[e]),[o,s]=(0,r.useState)((()=>f(n)));(0,r.useEffect)((()=>{s(function(e){let{pluginIds:t,versionPersistence:n,allDocsData:r}=e;function a(e){const t=p.read(e,n);return r[e].versions.some((e=>e.name===t))?{preferredVersionName:t}:(p.clear(e,n),{preferredVersionName:null})}return Object.fromEntries(t.map((e=>[e,a(e)])))}({allDocsData:e,versionPersistence:t,pluginIds:n}))}),[e,t,n]);return[o,(0,r.useMemo)((()=>({savePreferredVersion:function(e,n){p.save(e,t,n),s((t=>({...t,[e]:{preferredVersionName:n}})))}})),[t])]}function m(e){let{children:t}=e;const n=g();return(0,u.jsx)(h.Provider,{value:n,children:t})}function b(e){let{children:t}=e;return s.C5?(0,u.jsx)(m,{children:t}):(0,u.jsx)(u.Fragment,{children:t})}function y(){const e=(0,r.useContext)(h);if(!e)throw new l.dV("DocsPreferredVersionContextProvider");return e}function v(e){void 0===e&&(e=o.W);const t=(0,a.ht)(e),[n,i]=y(),{preferredVersionName:s}=n[e];return{preferredVersion:t.versions.find((e=>e.name===s))??null,savePreferredVersionName:(0,r.useCallback)((t=>{i.savePreferredVersion(e,t)}),[i,e])}}function w(){const e=(0,a.Gy)(),[t]=y();function n(n){const r=e[n],{preferredVersionName:a}=t[n];return r.versions.find((e=>e.name===a))??null}const r=Object.keys(e);return Object.fromEntries(r.map((e=>[e,n(e)])))}},26588:(e,t,n)=>{"use strict";n.d(t,{V:()=>l,t:()=>c});var r=n(96540),a=n(89532),o=n(74848);const i=Symbol("EmptyContext"),s=r.createContext(i);function l(e){let{children:t,name:n,items:a}=e;const i=(0,r.useMemo)((()=>n&&a?{name:n,items:a}:null),[n,a]);return(0,o.jsx)(s.Provider,{value:i,children:t})}function c(){const e=(0,r.useContext)(s);if(e===i)throw new a.dV("DocsSidebarProvider");return e}},32252:(e,t,n)=>{"use strict";n.d(t,{n:()=>s,r:()=>l});var r=n(96540),a=n(89532),o=n(74848);const i=r.createContext(null);function s(e){let{children:t,version:n}=e;return(0,o.jsx)(i.Provider,{value:n,children:t})}function l(){const e=(0,r.useContext)(i);if(null===e)throw new a.dV("DocsVersionProvider");return e}},22069:(e,t,n)=>{"use strict";n.d(t,{M:()=>f,e:()=>p});var r=n(96540),a=n(75600),o=n(24581),i=n(57485),s=n(6342),l=n(89532),c=n(74848);const u=r.createContext(void 0);function d(){const e=function(){const e=(0,a.YL)(),{items:t}=(0,s.p)().navbar;return 0===t.length&&!e.component}(),t=(0,o.l)(),n=!e&&"mobile"===t,[l,c]=(0,r.useState)(!1);(0,i.$Z)((()=>{if(l)return c(!1),!1}));const u=(0,r.useCallback)((()=>{c((e=>!e))}),[]);return(0,r.useEffect)((()=>{"desktop"===t&&c(!1)}),[t]),(0,r.useMemo)((()=>({disabled:e,shouldRender:n,toggle:u,shown:l})),[e,n,u,l])}function p(e){let{children:t}=e;const n=d();return(0,c.jsx)(u.Provider,{value:n,children:t})}function f(){const e=r.useContext(u);if(void 0===e)throw new l.dV("NavbarMobileSidebarProvider");return e}},75600:(e,t,n)=>{"use strict";n.d(t,{GX:()=>c,YL:()=>l,y_:()=>s});var r=n(96540),a=n(89532),o=n(74848);const i=r.createContext(null);function s(e){let{children:t}=e;const n=(0,r.useState)({component:null,props:null});return(0,o.jsx)(i.Provider,{value:n,children:t})}function l(){const e=(0,r.useContext)(i);if(!e)throw new a.dV("NavbarSecondaryMenuContentProvider");return e[0]}function c(e){let{component:t,props:n}=e;const o=(0,r.useContext)(i);if(!o)throw new a.dV("NavbarSecondaryMenuContentProvider");const[,s]=o,l=(0,a.Be)(n);return(0,r.useEffect)((()=>{s({component:t,props:l})}),[s,t,l]),(0,r.useEffect)((()=>()=>s({component:null,props:null})),[s]),null}},14090:(e,t,n)=>{"use strict";n.d(t,{w:()=>a,J:()=>o});var r=n(96540);const a="navigation-with-keyboard";function o(){(0,r.useEffect)((()=>{function e(e){"keydown"===e.type&&"Tab"===e.key&&document.body.classList.add(a),"mousedown"===e.type&&document.body.classList.remove(a)}return document.addEventListener("keydown",e),document.addEventListener("mousedown",e),()=>{document.body.classList.remove(a),document.removeEventListener("keydown",e),document.removeEventListener("mousedown",e)}}),[])}},24255:(e,t,n)=>{"use strict";n.d(t,{b:()=>s,w:()=>l});var r=n(96540),a=n(44586),o=n(57485);const i="q";function s(){return(0,o.l)(i)}function l(){const{siteConfig:{baseUrl:e,themeConfig:t}}=(0,a.A)(),{algolia:{searchPagePath:n}}=t;return(0,r.useCallback)((t=>`${e}${n}?${i}=${encodeURIComponent(t)}`),[e,n])}},24581:(e,t,n)=>{"use strict";n.d(t,{l:()=>s});var r=n(96540),a=n(38193);const o={desktop:"desktop",mobile:"mobile",ssr:"ssr"},i=996;function s(e){let{desktopBreakpoint:t=i}=void 0===e?{}:e;const[n,s]=(0,r.useState)((()=>"ssr"));return(0,r.useEffect)((()=>{function e(){s(function(e){if(!a.A.canUseDOM)throw new Error("getWindowSize() should only be called after React hydration");return window.innerWidth>e?o.desktop:o.mobile}(t))}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[t]),n}},17559:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});const r={page:{blogListPage:"blog-list-page",blogPostPage:"blog-post-page",blogTagsListPage:"blog-tags-list-page",blogTagPostListPage:"blog-tags-post-list-page",docsDocPage:"docs-doc-page",docsTagsListPage:"docs-tags-list-page",docsTagDocListPage:"docs-tags-doc-list-page",mdxPage:"mdx-page"},wrapper:{main:"main-wrapper",blogPages:"blog-wrapper",docsPages:"docs-wrapper",mdxPages:"mdx-wrapper"},common:{editThisPage:"theme-edit-this-page",lastUpdated:"theme-last-updated",backToTopButton:"theme-back-to-top-button",codeBlock:"theme-code-block",admonition:"theme-admonition",unlistedBanner:"theme-unlisted-banner",admonitionType:e=>`theme-admonition-${e}`},layout:{},docs:{docVersionBanner:"theme-doc-version-banner",docVersionBadge:"theme-doc-version-badge",docBreadcrumbs:"theme-doc-breadcrumbs",docMarkdown:"theme-doc-markdown",docTocMobile:"theme-doc-toc-mobile",docTocDesktop:"theme-doc-toc-desktop",docFooter:"theme-doc-footer",docFooterTagsRow:"theme-doc-footer-tags-row",docFooterEditMetaRow:"theme-doc-footer-edit-meta-row",docSidebarContainer:"theme-doc-sidebar-container",docSidebarMenu:"theme-doc-sidebar-menu",docSidebarItemCategory:"theme-doc-sidebar-item-category",docSidebarItemLink:"theme-doc-sidebar-item-link",docSidebarItemCategoryLevel:e=>`theme-doc-sidebar-item-category-level-${e}`,docSidebarItemLinkLevel:e=>`theme-doc-sidebar-item-link-level-${e}`},blog:{blogFooterTagsRow:"theme-blog-footer-tags-row",blogFooterEditMetaRow:"theme-blog-footer-edit-meta-row"}}},53109:(e,t,n)=>{"use strict";function r(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}n.d(t,{O:()=>r})},84142:(e,t,n)=>{"use strict";n.d(t,{$S:()=>g,B5:()=>C,C5:()=>p,Nr:()=>h,OF:()=>x,QB:()=>E,Vd:()=>S,Y:()=>w,cC:()=>f,d1:()=>T,fW:()=>_,w8:()=>y});var r=n(96540),a=n(56347),o=n(22831),i=n(44070),s=n(55597),l=n(32252),c=n(26588),u=n(31682),d=n(99169);const p=!!i.Gy;function f(e){const t=(0,l.r)();if(!e)return;const n=t.docs[e];if(!n)throw new Error(`no version doc found by id=${e}`);return n}function h(e){return"link"!==e.type||e.unlisted?"category"===e.type?function(e){if(e.href&&!e.linkUnlisted)return e.href;for(const t of e.items){const e=h(t);if(e)return e}}(e):void 0:e.href}function g(){const{pathname:e}=(0,a.zy)(),t=(0,c.t)();if(!t)throw new Error("Unexpected: cant find current sidebar in context");const n=k({sidebarItems:t.items,pathname:e,onlyCategories:!0}).slice(-1)[0];if(!n)throw new Error(`${e} is not associated with a category. useCurrentSidebarCategory() should only be used on category index pages.`);return n}const m=(e,t)=>void 0!==e&&(0,d.ys)(e,t),b=(e,t)=>e.some((e=>y(e,t)));function y(e,t){return"link"===e.type?m(e.href,t):"category"===e.type&&(m(e.href,t)||b(e.items,t))}function v(e,t){switch(e.type){case"category":return y(e,t)||e.items.some((e=>v(e,t)));case"link":return!e.unlisted||y(e,t);default:return!0}}function w(e,t){return(0,r.useMemo)((()=>e.filter((e=>v(e,t)))),[e,t])}function k(e){let{sidebarItems:t,pathname:n,onlyCategories:r=!1}=e;const a=[];return function e(t){for(const o of t)if("category"===o.type&&((0,d.ys)(o.href,n)||e(o.items))||"link"===o.type&&(0,d.ys)(o.href,n)){return r&&"category"!==o.type||a.unshift(o),!0}return!1}(t),a}function x(){const e=(0,c.t)(),{pathname:t}=(0,a.zy)(),n=(0,i.vT)()?.pluginData.breadcrumbs;return!1!==n&&e?k({sidebarItems:e.items,pathname:t}):null}function S(e){const{activeVersion:t}=(0,i.zK)(e),{preferredVersion:n}=(0,s.g1)(e),a=(0,i.r7)(e);return(0,r.useMemo)((()=>(0,u.s)([t,n,a].filter(Boolean))),[t,n,a])}function _(e,t){const n=S(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.sidebars?Object.entries(e.sidebars):[])),r=t.find((t=>t[0]===e));if(!r)throw new Error(`Can't find any sidebar with id "${e}" in version${n.length>1?"s":""} ${n.map((e=>e.name)).join(", ")}".\nAvailable sidebar ids are:\n- ${t.map((e=>e[0])).join("\n- ")}`);return r[1]}),[e,n])}function E(e,t){const n=S(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.docs)),r=t.find((t=>t.id===e));if(!r){if(n.flatMap((e=>e.draftIds)).includes(e))return null;throw new Error(`Couldn't find any doc with id "${e}" in version${n.length>1?"s":""} "${n.map((e=>e.name)).join(", ")}".\nAvailable doc ids are:\n- ${(0,u.s)(t.map((e=>e.id))).join("\n- ")}`)}return r}),[e,n])}function C(e){let{route:t}=e;const n=(0,a.zy)(),r=(0,l.r)(),i=t.routes,s=i.find((e=>(0,a.B6)(n.pathname,e)));if(!s)return null;const c=s.sidebar,u=c?r.docsSidebars[c]:void 0;return{docElement:(0,o.v)(i),sidebarName:c,sidebarItems:u}}function T(e){return e.filter((e=>!("category"===e.type||"link"===e.type)||!!h(e)))}},12181:(e,t,n)=>{"use strict";n.d(t,{bq:()=>u,MN:()=>c,a2:()=>l,k2:()=>d});var r=n(96540),a=n(21312),o=n(70440);const i={errorBoundaryError:"errorBoundaryError_a6uf",errorBoundaryFallback:"errorBoundaryFallback_VBag"};var s=n(74848);function l(e){return(0,s.jsx)("button",{type:"button",...e,children:(0,s.jsx)(a.A,{id:"theme.ErrorPageContent.tryAgain",description:"The label of the button to try again rendering when the React error boundary captures an error",children:"Try again"})})}function c(e){let{error:t,tryAgain:n}=e;return(0,s.jsxs)("div",{className:i.errorBoundaryFallback,children:[(0,s.jsx)("p",{children:t.message}),(0,s.jsx)(l,{onClick:n})]})}function u(e){let{error:t}=e;const n=(0,o.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,s.jsx)("p",{className:i.errorBoundaryError,children:n})}class d extends r.Component{componentDidCatch(e,t){throw this.props.onError(e,t)}render(){return this.props.children}}},20481:(e,t,n)=>{"use strict";n.d(t,{s:()=>a});var r=n(44586);function a(e){const{siteConfig:t}=(0,r.A)(),{title:n,titleDelimiter:a}=t;return e?.trim().length?`${e.trim()} ${a} ${n}`:n}},57485:(e,t,n)=>{"use strict";n.d(t,{$Z:()=>i,aZ:()=>s,l:()=>l});var r=n(96540),a=n(56347),o=n(89532);function i(e){!function(e){const t=(0,a.W6)(),n=(0,o._q)(e);(0,r.useEffect)((()=>t.block(((e,t)=>n(e,t)))),[t,n])}(((t,n)=>{if("POP"===n)return e(t,n)}))}function s(e){return function(e){const t=(0,a.W6)();return(0,r.useSyncExternalStore)(t.listen,(()=>e(t)),(()=>e(t)))}((t=>null===e?null:new URLSearchParams(t.location.search).get(e)))}function l(e){const t=s(e)??"",n=function(){const e=(0,a.W6)();return(0,r.useCallback)(((t,n,r)=>{const a=new URLSearchParams(e.location.search);n?a.set(t,n):a.delete(t),(r?.push?e.push:e.replace)({search:a.toString()})}),[e])}();return[t,(0,r.useCallback)(((t,r)=>{n(e,t,r)}),[n,e])]}},31682:(e,t,n)=>{"use strict";function r(e,t){return void 0===t&&(t=(e,t)=>e===t),e.filter(((n,r)=>e.findIndex((e=>t(e,n)))!==r))}function a(e){return Array.from(new Set(e))}n.d(t,{X:()=>r,s:()=>a})},45500:(e,t,n)=>{"use strict";n.d(t,{Jx:()=>f,be:()=>u,e3:()=>p});var r=n(96540),a=n(15066),o=n(5260),i=n(36803),s=n(86025),l=n(20481),c=n(74848);function u(e){let{title:t,description:n,keywords:r,image:a,children:i}=e;const u=(0,l.s)(t),{withBaseUrl:d}=(0,s.h)(),p=a?d(a,{absolute:!0}):void 0;return(0,c.jsxs)(o.A,{children:[t&&(0,c.jsx)("title",{children:u}),t&&(0,c.jsx)("meta",{property:"og:title",content:u}),n&&(0,c.jsx)("meta",{name:"description",content:n}),n&&(0,c.jsx)("meta",{property:"og:description",content:n}),r&&(0,c.jsx)("meta",{name:"keywords",content:Array.isArray(r)?r.join(","):r}),p&&(0,c.jsx)("meta",{property:"og:image",content:p}),p&&(0,c.jsx)("meta",{name:"twitter:image",content:p}),i]})}const d=r.createContext(void 0);function p(e){let{className:t,children:n}=e;const i=r.useContext(d),s=(0,a.A)(i,t);return(0,c.jsxs)(d.Provider,{value:s,children:[(0,c.jsx)(o.A,{children:(0,c.jsx)("html",{className:s})}),n]})}function f(e){let{children:t}=e;const n=(0,i.A)(),r=`plugin-${n.plugin.name.replace(/docusaurus-(?:plugin|theme)-(?:content-)?/gi,"")}`;const o=`plugin-id-${n.plugin.id}`;return(0,c.jsx)(p,{className:(0,a.A)(r,o),children:t})}},89532:(e,t,n)=>{"use strict";n.d(t,{Be:()=>c,ZC:()=>s,_q:()=>i,dV:()=>l,fM:()=>u});var r=n(96540),a=n(205),o=n(74848);function i(e){const t=(0,r.useRef)(e);return(0,a.A)((()=>{t.current=e}),[e]),(0,r.useCallback)((function(){return t.current(...arguments)}),[])}function s(e){const t=(0,r.useRef)();return(0,a.A)((()=>{t.current=e})),t.current}class l extends Error{constructor(e,t){super(),this.name="ReactContextError",this.message=`Hook ${this.stack?.split("\n")[1]?.match(/at (?:\w+\.)?(?\w+)/)?.groups.name??""} is called outside the <${e}>. ${t??""}`}}function c(e){const t=Object.entries(e);return t.sort(((e,t)=>e[0].localeCompare(t[0]))),(0,r.useMemo)((()=>e),t.flat())}function u(e){return t=>{let{children:n}=t;return(0,o.jsx)(o.Fragment,{children:e.reduceRight(((e,t)=>(0,o.jsx)(t,{children:e})),n)})}}},91252:(e,t,n)=>{"use strict";function r(e,t){return void 0!==e&&void 0!==t&&new RegExp(e,"gi").test(t)}n.d(t,{G:()=>r})},99169:(e,t,n)=>{"use strict";n.d(t,{Dt:()=>s,ys:()=>i});var r=n(96540),a=n(35947),o=n(44586);function i(e,t){const n=e=>(!e||e.endsWith("/")?e:`${e}/`)?.toLowerCase();return n(e)===n(t)}function s(){const{baseUrl:e}=(0,o.A)().siteConfig;return(0,r.useMemo)((()=>function(e){let{baseUrl:t,routes:n}=e;function r(e){return e.path===t&&!0===e.exact}function a(e){return e.path===t&&!e.exact}return function e(t){if(0===t.length)return;return t.find(r)||e(t.filter(a).flatMap((e=>e.routes??[])))}(n)}({routes:a.A,baseUrl:e})),[e])}},23104:(e,t,n)=>{"use strict";n.d(t,{Mq:()=>f,Tv:()=>u,a_:()=>h,gk:()=>g});var r=n(96540),a=n(38193),o=n(92303),i=n(205),s=n(89532),l=n(74848);const c=r.createContext(void 0);function u(e){let{children:t}=e;const n=function(){const e=(0,r.useRef)(!0);return(0,r.useMemo)((()=>({scrollEventsEnabledRef:e,enableScrollEvents:()=>{e.current=!0},disableScrollEvents:()=>{e.current=!1}})),[])}();return(0,l.jsx)(c.Provider,{value:n,children:t})}function d(){const e=(0,r.useContext)(c);if(null==e)throw new s.dV("ScrollControllerProvider");return e}const p=()=>a.A.canUseDOM?{scrollX:window.pageXOffset,scrollY:window.pageYOffset}:null;function f(e,t){void 0===t&&(t=[]);const{scrollEventsEnabledRef:n}=d(),a=(0,r.useRef)(p()),o=(0,s._q)(e);(0,r.useEffect)((()=>{const e=()=>{if(!n.current)return;const e=p();o(e,a.current),a.current=e},t={passive:!0};return e(),window.addEventListener("scroll",e,t),()=>window.removeEventListener("scroll",e,t)}),[o,n,...t])}function h(){const e=d(),t=function(){const e=(0,r.useRef)({elem:null,top:0}),t=(0,r.useCallback)((t=>{e.current={elem:t,top:t.getBoundingClientRect().top}}),[]),n=(0,r.useCallback)((()=>{const{current:{elem:t,top:n}}=e;if(!t)return{restored:!1};const r=t.getBoundingClientRect().top-n;return r&&window.scrollBy({left:0,top:r}),e.current={elem:null,top:0},{restored:0!==r}}),[]);return(0,r.useMemo)((()=>({save:t,restore:n})),[n,t])}(),n=(0,r.useRef)(void 0),a=(0,r.useCallback)((r=>{t.save(r),e.disableScrollEvents(),n.current=()=>{const{restored:r}=t.restore();if(n.current=void 0,r){const t=()=>{e.enableScrollEvents(),window.removeEventListener("scroll",t)};window.addEventListener("scroll",t)}else e.enableScrollEvents()}}),[e,t]);return(0,i.A)((()=>{queueMicrotask((()=>n.current?.()))})),{blockElementScrollPositionUntilNextRender:a}}function g(){const e=(0,r.useRef)(null),t=(0,o.A)()&&"smooth"===getComputedStyle(document.documentElement).scrollBehavior;return{startScroll:n=>{e.current=t?function(e){return window.scrollTo({top:e,behavior:"smooth"}),()=>{}}(n):function(e){let t=null;const n=document.documentElement.scrollTop>e;return function r(){const a=document.documentElement.scrollTop;(n&&a>e||!n&&at&&cancelAnimationFrame(t)}(n)},cancelScroll:()=>e.current?.()}}},2967:(e,t,n)=>{"use strict";n.d(t,{Cy:()=>i,af:()=>l,tU:()=>s});var r=n(44070),a=n(44586),o=n(55597);const i="default";function s(e,t){return`docs-${e}-${t}`}function l(){const{i18n:e}=(0,a.A)(),t=(0,r.Gy)(),n=(0,r.gk)(),l=(0,o.XK)();const c=[i,...Object.keys(t).map((function(e){const r=n?.activePlugin.pluginId===e?n.activeVersion:void 0,a=l[e],o=t[e].versions.find((e=>e.isLast));return s(e,(r??a??o).name)}))];return{locale:e.currentLocale,tags:c}}},89466:(e,t,n)=>{"use strict";n.d(t,{Dv:()=>u,Wf:()=>c});var r=n(96540);const a="localStorage";function o(e){let{key:t,oldValue:n,newValue:r,storage:a}=e;if(n===r)return;const o=document.createEvent("StorageEvent");o.initStorageEvent("storage",!1,!1,t,n,r,window.location.href,a),window.dispatchEvent(o)}function i(e){if(void 0===e&&(e=a),"undefined"==typeof window)throw new Error("Browser storage is not available on Node.js/Docusaurus SSR process.");if("none"===e)return null;try{return window[e]}catch(n){return t=n,s||(console.warn("Docusaurus browser storage is not available.\nPossible reasons: running Docusaurus in an iframe, in an incognito browser session, or using too strict browser privacy settings.",t),s=!0),null}var t}let s=!1;const l={get:()=>null,set:()=>{},del:()=>{},listen:()=>()=>{}};function c(e,t){if("undefined"==typeof window)return function(e){function t(){throw new Error(`Illegal storage API usage for storage key "${e}".\nDocusaurus storage APIs are not supposed to be called on the server-rendering process.\nPlease only call storage APIs in effects and event handlers.`)}return{get:t,set:t,del:t,listen:t}}(e);const n=i(t?.persistence);return null===n?l:{get:()=>{try{return n.getItem(e)}catch(t){return console.error(`Docusaurus storage error, can't get key=${e}`,t),null}},set:t=>{try{const r=n.getItem(e);n.setItem(e,t),o({key:e,oldValue:r,newValue:t,storage:n})}catch(r){console.error(`Docusaurus storage error, can't set ${e}=${t}`,r)}},del:()=>{try{const t=n.getItem(e);n.removeItem(e),o({key:e,oldValue:t,newValue:null,storage:n})}catch(t){console.error(`Docusaurus storage error, can't delete key=${e}`,t)}},listen:t=>{try{const r=r=>{r.storageArea===n&&r.key===e&&t(r)};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)}catch(r){return console.error(`Docusaurus storage error, can't listen for changes of key=${e}`,r),()=>{}}}}}function u(e,t){const n=(0,r.useRef)((()=>null===e?l:c(e,t))).current(),a=(0,r.useCallback)((e=>"undefined"==typeof window?()=>{}:n.listen(e)),[n]);return[(0,r.useSyncExternalStore)(a,(()=>"undefined"==typeof window?null:n.get()),(()=>null)),n]}},32131:(e,t,n)=>{"use strict";n.d(t,{o:()=>i});var r=n(44586),a=n(56347),o=n(70440);function i(){const{siteConfig:{baseUrl:e,url:t,trailingSlash:n},i18n:{defaultLocale:i,currentLocale:s}}=(0,r.A)(),{pathname:l}=(0,a.zy)(),c=(0,o.applyTrailingSlash)(l,{trailingSlash:n,baseUrl:e}),u=s===i?e:e.replace(`/${s}/`,"/"),d=c.replace(e,"");return{createUrl:function(e){let{locale:n,fullyQualified:r}=e;return`${r?t:""}${function(e){return e===i?`${u}`:`${u}${e}/`}(n)}${d}`}}}},75062:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(96540),a=n(56347),o=n(89532);function i(e){const t=(0,a.zy)(),n=(0,o.ZC)(t),i=(0,o._q)(e);(0,r.useEffect)((()=>{n&&t!==n&&i({location:t,previousLocation:n})}),[i,t,n])}},6342:(e,t,n)=>{"use strict";n.d(t,{p:()=>a});var r=n(44586);function a(){return(0,r.A)().siteConfig.themeConfig}},38126:(e,t,n)=>{"use strict";n.d(t,{c:()=>a});var r=n(44586);function a(){const{siteConfig:{themeConfig:e}}=(0,r.A)();return e}},51062:(e,t,n)=>{"use strict";n.d(t,{C:()=>s});var r=n(96540),a=n(91252),o=n(86025),i=n(38126);function s(){const{withBaseUrl:e}=(0,o.h)(),{algolia:{externalUrlRegex:t,replaceSearchResultPathname:n}}=(0,i.c)();return(0,r.useCallback)((r=>{const o=new URL(r);if((0,a.G)(t,o.href))return r;const i=`${o.pathname+o.hash}`;return e(function(e,t){return t?e.replaceAll(new RegExp(t.from,"g"),t.to):e}(i,n))}),[e,t,n])}},12983:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeTrailingSlash=t.addLeadingSlash=t.addTrailingSlash=void 0;const r=n(42566);function a(e){return e.endsWith("/")?e:`${e}/`}function o(e){return(0,r.removeSuffix)(e,"/")}t.addTrailingSlash=a,t.default=function(e,t){const{trailingSlash:n,baseUrl:r}=t;if(e.startsWith("#"))return e;if(void 0===n)return e;const[i]=e.split(/[#?]/),s="/"===i||i===r?i:(l=i,n?a(l):o(l));var l;return e.replace(i,s)},t.addLeadingSlash=function(e){return(0,r.addPrefix)(e,"/")},t.removeTrailingSlash=o},80253:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=void 0,t.getErrorCausalChain=function e(t){return t.cause?[t,...e(t.cause)]:[t]}},70440:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=t.removePrefix=t.addSuffix=t.removeSuffix=t.addPrefix=t.removeTrailingSlash=t.addLeadingSlash=t.addTrailingSlash=t.applyTrailingSlash=t.blogPostContainerID=void 0,t.blogPostContainerID="__blog-post-container";var a=n(12983);Object.defineProperty(t,"applyTrailingSlash",{enumerable:!0,get:function(){return r(a).default}}),Object.defineProperty(t,"addTrailingSlash",{enumerable:!0,get:function(){return a.addTrailingSlash}}),Object.defineProperty(t,"addLeadingSlash",{enumerable:!0,get:function(){return a.addLeadingSlash}}),Object.defineProperty(t,"removeTrailingSlash",{enumerable:!0,get:function(){return a.removeTrailingSlash}});var o=n(42566);Object.defineProperty(t,"addPrefix",{enumerable:!0,get:function(){return o.addPrefix}}),Object.defineProperty(t,"removeSuffix",{enumerable:!0,get:function(){return o.removeSuffix}}),Object.defineProperty(t,"addSuffix",{enumerable:!0,get:function(){return o.addSuffix}}),Object.defineProperty(t,"removePrefix",{enumerable:!0,get:function(){return o.removePrefix}});var i=n(80253);Object.defineProperty(t,"getErrorCausalChain",{enumerable:!0,get:function(){return i.getErrorCausalChain}})},42566:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removePrefix=t.addSuffix=t.removeSuffix=t.addPrefix=void 0,t.addPrefix=function(e,t){return e.startsWith(t)?e:`${t}${e}`},t.removeSuffix=function(e,t){return""===t?e:e.endsWith(t)?e.slice(0,-t.length):e},t.addSuffix=function(e,t){return e.endsWith(t)?e:`${e}${t}`},t.removePrefix=function(e,t){return e.startsWith(t)?e.slice(t.length):e}},31513:(e,t,n)=>{"use strict";n.d(t,{zR:()=>w,TM:()=>C,yJ:()=>f,sC:()=>A,AO:()=>p});var r=n(58168);function a(e){return"/"===e.charAt(0)}function o(e,t){for(var n=t,r=n+1,a=e.length;r=0;p--){var f=i[p];"."===f?o(i,p):".."===f?(o(i,p),d++):d&&(o(i,p),d--)}if(!c)for(;d--;d)i.unshift("..");!c||""===i[0]||i[0]&&a(i[0])||i.unshift("");var h=i.join("/");return n&&"/"!==h.substr(-1)&&(h+="/"),h};var s=n(11561);function l(e){return"/"===e.charAt(0)?e:"/"+e}function c(e){return"/"===e.charAt(0)?e.substr(1):e}function u(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function d(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function p(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function f(e,t,n,a){var o;"string"==typeof e?(o=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),o.state=t):(void 0===(o=(0,r.A)({},e)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==t&&void 0===o.state&&(o.state=t));try{o.pathname=decodeURI(o.pathname)}catch(s){throw s instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):s}return n&&(o.key=n),a?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=i(o.pathname,a.pathname)):o.pathname=a.pathname:o.pathname||(o.pathname="/"),o}function h(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var o="function"==typeof e?e(t,n):e;"string"==typeof o?"function"==typeof r?r(o,a):a(!0):a(!1!==o)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,a):n.push(a),d({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",a=f(e,t,g(),w.location);u.confirmTransitionTo(a,r,n,(function(e){e&&(w.entries[w.index]=a,d({action:r,location:a}))}))},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(e){var t=w.index+e;return t>=0&&t{"use strict";var r=n(44363),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?i:s[e.$$typeof]||a}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=i;var c=Object.defineProperty,u=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(h){var a=f(n);a&&a!==h&&e(t,a,r)}var i=u(n);d&&(i=i.concat(d(n)));for(var s=l(t),g=l(n),m=0;m{"use strict";e.exports=function(e,t,n,r,a,o,i,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,a,o,i,s],u=0;(l=new Error(t.replace(/%s/g,(function(){return c[u++]})))).name="Invariant Violation"}throw l.framesToPop=1,l}}},64634:e=>{e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},10119:(e,t,n)=>{"use strict";n.r(t)},51043:(e,t,n)=>{"use strict";n.r(t)},5947:function(e,t,n){var r,a;r=function(){var e,t,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function a(e,t,n){return en?n:e}function o(e){return 100*(-1+e)}function i(e,t,n){var a;return(a="translate3d"===r.positionUsing?{transform:"translate3d("+o(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+o(e)+"%,0)"}:{"margin-left":o(e)+"%"}).transition="all "+t+"ms "+n,a}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=a(e,r.minimum,1),n.status=1===e?null:e;var o=n.render(!t),c=o.querySelector(r.barSelector),u=r.speed,d=r.easing;return o.offsetWidth,s((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),l(c,i(e,u,d)),1===e?(l(o,{transition:"none",opacity:1}),o.offsetWidth,setTimeout((function(){l(o,{transition:"all "+u+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),u)}),u)):setTimeout(t,u)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*a(Math.random()*t,.1,.95)),t=a(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");u(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var a,i=t.querySelector(r.barSelector),s=e?"-100":o(n.status||0),c=document.querySelector(r.parent);return l(i,{transition:"all 0 linear",transform:"translate3d("+s+"%,0,0)"}),r.showSpinner||(a=t.querySelector(r.spinnerSelector))&&f(a),c!=document.body&&u(c,"nprogress-custom-parent"),c.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&f(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var s=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),l=function(){var e=["Webkit","O","Moz","ms"],t={};function n(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function r(t){var n=document.body.style;if(t in n)return t;for(var r,a=e.length,o=t.charAt(0).toUpperCase()+t.slice(1);a--;)if((r=e[a]+o)in n)return r;return t}function a(e){return e=n(e),t[e]||(t[e]=r(e))}function o(e,t,n){t=a(t),e.style[t]=n}return function(e,t){var n,r,a=arguments;if(2==a.length)for(n in t)void 0!==(r=t[n])&&t.hasOwnProperty(n)&&o(e,n,r);else o(e,a[1],a[2])}}();function c(e,t){return("string"==typeof e?e:p(e)).indexOf(" "+t+" ")>=0}function u(e,t){var n=p(e),r=n+t;c(n,t)||(e.className=r.substring(1))}function d(e,t){var n,r=p(e);c(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function p(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function f(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n},void 0===(a="function"==typeof r?r.call(t,n,t,e):r)||(e.exports=a)},35302:(e,t,n)=>{var r=n(64634);e.exports=f,e.exports.parse=o,e.exports.compile=function(e,t){return s(o(e,t),t)},e.exports.tokensToFunction=s,e.exports.tokensToRegExp=p;var a=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function o(e,t){for(var n,r=[],o=0,i=0,s="",u=t&&t.delimiter||"/";null!=(n=a.exec(e));){var d=n[0],p=n[1],f=n.index;if(s+=e.slice(i,f),i=f+d.length,p)s+=p[1];else{var h=e[i],g=n[2],m=n[3],b=n[4],y=n[5],v=n[6],w=n[7];s&&(r.push(s),s="");var k=null!=g&&null!=h&&h!==g,x="+"===v||"*"===v,S="?"===v||"*"===v,_=n[2]||u,E=b||y;r.push({name:m||o++,prefix:g||"",delimiter:_,optional:S,repeat:x,partial:k,asterisk:!!w,pattern:E?c(E):w?".*":"[^"+l(_)+"]+?"})}}return i{!function(e){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,i=0;i{!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,a,o){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(a,(function(e){if("function"==typeof o&&!o(e))return e;for(var a,s=i.length;-1!==n.code.indexOf(a=t(r,s));)++s;return i[s]=e,a})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var a=0,o=Object.keys(n.tokenStack);!function i(s){for(var l=0;l=o.length);l++){var c=s[l];if("string"==typeof c||c.content&&"string"==typeof c.content){var u=o[a],d=n.tokenStack[u],p="string"==typeof c?c:c.content,f=t(r,u),h=p.indexOf(f);if(h>-1){++a;var g=p.substring(0,h),m=new e.Token(r,e.tokenize(d,n.grammar),"language-"+r,d),b=p.substring(h+f.length),y=[];g&&y.push.apply(y,i([g])),y.push(m),b&&y.push.apply(y,i([b])),"string"==typeof c?s.splice.apply(s,[l,1].concat(y)):c.content=y}}else c.content&&i(c.content)}return s}(n.tokens)}}}})}(Prism)},30905:()=>{!function(e){var t=e.languages.powershell={comment:[{pattern:/(^|[^`])<#[\s\S]*?#>/,lookbehind:!0},{pattern:/(^|[^`])#.*/,lookbehind:!0}],string:[{pattern:/"(?:`[\s\S]|[^`"])*"/,greedy:!0,inside:null},{pattern:/'(?:[^']|'')*'/,greedy:!0}],namespace:/\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,boolean:/\$(?:false|true)\b/i,variable:/\$\w+\b/,function:[/\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i],keyword:/\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,operator:{pattern:/(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,lookbehind:!0},punctuation:/[|{}[\];(),.]/};t.string[0].inside={function:{pattern:/(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,lookbehind:!0,inside:t},boolean:t.boolean,variable:t.variable}}(Prism)},52342:()=>{Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python},75342:()=>{!function(e){for(var t=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|)*\*\//.source,n=0;n<2;n++)t=t.replace(//g,(function(){return t}));t=t.replace(//g,(function(){return/[^\s\S]/.source})),e.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<>?=?|[@?]/},e.languages.rust["closure-params"].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string}(Prism)},10900:(e,t,n)=>{var r={"./prism-bash":57022,"./prism-powershell":30905,"./prism-python":52342,"./prism-rust":75342};function a(e){var t=o(e);return n(t)}function o(e){if(!n.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}a.keys=function(){return Object.keys(r)},a.resolve=o,e.exports=a,a.id=10900},2694:(e,t,n)=>{"use strict";var r=n(6925);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,i){if(i!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},22551:(e,t,n)=>{"use strict";var r=n(96540),a=n(69982);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n