viam-sdk 0.45.2__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of viam-sdk might be problematic. Click here for more details.

Files changed (476) hide show
  1. viam/__init__.py +71 -0
  2. viam/app/__init__.py +0 -0
  3. viam/app/_logs.py +34 -0
  4. viam/app/app_client.py +2525 -0
  5. viam/app/billing_client.py +143 -0
  6. viam/app/data_client.py +1715 -0
  7. viam/app/ml_training_client.py +251 -0
  8. viam/app/provisioning_client.py +95 -0
  9. viam/app/viam_client.py +260 -0
  10. viam/components/__init__.py +0 -0
  11. viam/components/arm/__init__.py +16 -0
  12. viam/components/arm/arm.py +223 -0
  13. viam/components/arm/client.py +124 -0
  14. viam/components/arm/service.py +123 -0
  15. viam/components/audio_input/__init__.py +18 -0
  16. viam/components/audio_input/audio_input.py +81 -0
  17. viam/components/audio_input/client.py +70 -0
  18. viam/components/audio_input/service.py +114 -0
  19. viam/components/base/__init__.py +13 -0
  20. viam/components/base/base.py +260 -0
  21. viam/components/base/client.py +153 -0
  22. viam/components/base/service.py +138 -0
  23. viam/components/board/__init__.py +9 -0
  24. viam/components/board/board.py +414 -0
  25. viam/components/board/client.py +241 -0
  26. viam/components/board/service.py +223 -0
  27. viam/components/button/__init__.py +10 -0
  28. viam/components/button/button.py +41 -0
  29. viam/components/button/client.py +52 -0
  30. viam/components/button/service.py +46 -0
  31. viam/components/camera/__init__.py +22 -0
  32. viam/components/camera/camera.py +138 -0
  33. viam/components/camera/client.py +98 -0
  34. viam/components/camera/service.py +105 -0
  35. viam/components/component_base.py +65 -0
  36. viam/components/encoder/__init__.py +18 -0
  37. viam/components/encoder/client.py +83 -0
  38. viam/components/encoder/encoder.py +118 -0
  39. viam/components/encoder/service.py +72 -0
  40. viam/components/gantry/__init__.py +11 -0
  41. viam/components/gantry/client.py +115 -0
  42. viam/components/gantry/gantry.py +156 -0
  43. viam/components/gantry/service.py +113 -0
  44. viam/components/generic/__init__.py +18 -0
  45. viam/components/generic/client.py +62 -0
  46. viam/components/generic/generic.py +76 -0
  47. viam/components/generic/service.py +40 -0
  48. viam/components/gripper/__init__.py +11 -0
  49. viam/components/gripper/client.py +85 -0
  50. viam/components/gripper/gripper.py +114 -0
  51. viam/components/gripper/service.py +81 -0
  52. viam/components/input/__init__.py +15 -0
  53. viam/components/input/client.py +194 -0
  54. viam/components/input/input.py +297 -0
  55. viam/components/input/service.py +175 -0
  56. viam/components/motor/__init__.py +11 -0
  57. viam/components/motor/client.py +168 -0
  58. viam/components/motor/motor.py +301 -0
  59. viam/components/motor/service.py +150 -0
  60. viam/components/movement_sensor/__init__.py +21 -0
  61. viam/components/movement_sensor/client.py +161 -0
  62. viam/components/movement_sensor/movement_sensor.py +253 -0
  63. viam/components/movement_sensor/service.py +146 -0
  64. viam/components/pose_tracker/__init__.py +17 -0
  65. viam/components/pose_tracker/client.py +50 -0
  66. viam/components/pose_tracker/pose_tracker.py +40 -0
  67. viam/components/pose_tracker/service.py +45 -0
  68. viam/components/power_sensor/__init__.py +17 -0
  69. viam/components/power_sensor/client.py +86 -0
  70. viam/components/power_sensor/power_sensor.py +104 -0
  71. viam/components/power_sensor/service.py +72 -0
  72. viam/components/sensor/__init__.py +18 -0
  73. viam/components/sensor/client.py +49 -0
  74. viam/components/sensor/sensor.py +48 -0
  75. viam/components/sensor/service.py +51 -0
  76. viam/components/servo/__init__.py +11 -0
  77. viam/components/servo/client.py +86 -0
  78. viam/components/servo/service.py +80 -0
  79. viam/components/servo/servo.py +114 -0
  80. viam/components/switch/__init__.py +10 -0
  81. viam/components/switch/client.py +83 -0
  82. viam/components/switch/service.py +72 -0
  83. viam/components/switch/switch.py +95 -0
  84. viam/errors.py +105 -0
  85. viam/gen/__init__.py +0 -0
  86. viam/gen/app/__init__.py +0 -0
  87. viam/gen/app/agent/__init__.py +0 -0
  88. viam/gen/app/agent/v1/__init__.py +0 -0
  89. viam/gen/app/agent/v1/agent_grpc.py +29 -0
  90. viam/gen/app/agent/v1/agent_pb2.py +47 -0
  91. viam/gen/app/agent/v1/agent_pb2.pyi +280 -0
  92. viam/gen/app/cloudslam/__init__.py +0 -0
  93. viam/gen/app/cloudslam/v1/__init__.py +0 -0
  94. viam/gen/app/cloudslam/v1/cloud_slam_grpc.py +70 -0
  95. viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +54 -0
  96. viam/gen/app/cloudslam/v1/cloud_slam_pb2.pyi +384 -0
  97. viam/gen/app/data/__init__.py +0 -0
  98. viam/gen/app/data/v1/__init__.py +0 -0
  99. viam/gen/app/data/v1/data_grpc.py +206 -0
  100. viam/gen/app/data/v1/data_pb2.py +178 -0
  101. viam/gen/app/data/v1/data_pb2.pyi +1485 -0
  102. viam/gen/app/datapipelines/__init__.py +0 -0
  103. viam/gen/app/datapipelines/v1/__init__.py +0 -0
  104. viam/gen/app/datapipelines/v1/data_pipelines_grpc.py +84 -0
  105. viam/gen/app/datapipelines/v1/data_pipelines_pb2.py +56 -0
  106. viam/gen/app/datapipelines/v1/data_pipelines_pb2.pyi +370 -0
  107. viam/gen/app/dataset/__init__.py +0 -0
  108. viam/gen/app/dataset/v1/__init__.py +0 -0
  109. viam/gen/app/dataset/v1/dataset_grpc.py +60 -0
  110. viam/gen/app/dataset/v1/dataset_pb2.py +40 -0
  111. viam/gen/app/dataset/v1/dataset_pb2.pyi +179 -0
  112. viam/gen/app/datasync/__init__.py +0 -0
  113. viam/gen/app/datasync/v1/__init__.py +0 -0
  114. viam/gen/app/datasync/v1/data_sync_grpc.py +47 -0
  115. viam/gen/app/datasync/v1/data_sync_pb2.py +70 -0
  116. viam/gen/app/datasync/v1/data_sync_pb2.pyi +425 -0
  117. viam/gen/app/mlinference/__init__.py +0 -0
  118. viam/gen/app/mlinference/v1/__init__.py +0 -0
  119. viam/gen/app/mlinference/v1/ml_inference_grpc.py +28 -0
  120. viam/gen/app/mlinference/v1/ml_inference_pb2.py +23 -0
  121. viam/gen/app/mlinference/v1/ml_inference_pb2.pyi +63 -0
  122. viam/gen/app/mltraining/__init__.py +0 -0
  123. viam/gen/app/mltraining/v1/__init__.py +0 -0
  124. viam/gen/app/mltraining/v1/ml_training_grpc.py +78 -0
  125. viam/gen/app/mltraining/v1/ml_training_pb2.py +124 -0
  126. viam/gen/app/mltraining/v1/ml_training_pb2.pyi +415 -0
  127. viam/gen/app/packages/__init__.py +0 -0
  128. viam/gen/app/packages/v1/__init__.py +0 -0
  129. viam/gen/app/packages/v1/packages_grpc.py +54 -0
  130. viam/gen/app/packages/v1/packages_pb2.py +52 -0
  131. viam/gen/app/packages/v1/packages_pb2.pyi +311 -0
  132. viam/gen/app/v1/__init__.py +0 -0
  133. viam/gen/app/v1/app_grpc.py +863 -0
  134. viam/gen/app/v1/app_pb2.py +649 -0
  135. viam/gen/app/v1/app_pb2.pyi +5279 -0
  136. viam/gen/app/v1/billing_grpc.py +76 -0
  137. viam/gen/app/v1/billing_pb2.py +92 -0
  138. viam/gen/app/v1/billing_pb2.pyi +463 -0
  139. viam/gen/app/v1/end_user_grpc.py +59 -0
  140. viam/gen/app/v1/end_user_pb2.py +55 -0
  141. viam/gen/app/v1/end_user_pb2.pyi +181 -0
  142. viam/gen/app/v1/robot_grpc.py +55 -0
  143. viam/gen/app/v1/robot_pb2.py +127 -0
  144. viam/gen/app/v1/robot_pb2.pyi +1202 -0
  145. viam/gen/common/__init__.py +0 -0
  146. viam/gen/common/v1/__init__.py +0 -0
  147. viam/gen/common/v1/common_grpc.py +0 -0
  148. viam/gen/common/v1/common_pb2.py +78 -0
  149. viam/gen/common/v1/common_pb2.pyi +687 -0
  150. viam/gen/component/__init__.py +0 -0
  151. viam/gen/component/arm/__init__.py +0 -0
  152. viam/gen/component/arm/v1/__init__.py +0 -0
  153. viam/gen/component/arm/v1/arm_grpc.py +102 -0
  154. viam/gen/component/arm/v1/arm_pb2.py +74 -0
  155. viam/gen/component/arm/v1/arm_pb2.pyi +344 -0
  156. viam/gen/component/audioinput/__init__.py +0 -0
  157. viam/gen/component/audioinput/v1/__init__.py +0 -0
  158. viam/gen/component/audioinput/v1/audioinput_grpc.py +63 -0
  159. viam/gen/component/audioinput/v1/audioinput_pb2.py +45 -0
  160. viam/gen/component/audioinput/v1/audioinput_pb2.pyi +179 -0
  161. viam/gen/component/base/__init__.py +0 -0
  162. viam/gen/component/base/v1/__init__.py +0 -0
  163. viam/gen/component/base/v1/base_grpc.py +94 -0
  164. viam/gen/component/base/v1/base_pb2.py +66 -0
  165. viam/gen/component/base/v1/base_pb2.pyi +258 -0
  166. viam/gen/component/board/__init__.py +0 -0
  167. viam/gen/component/board/v1/__init__.py +0 -0
  168. viam/gen/component/board/v1/board_grpc.py +127 -0
  169. viam/gen/component/board/v1/board_pb2.py +103 -0
  170. viam/gen/component/board/v1/board_pb2.pyi +496 -0
  171. viam/gen/component/button/__init__.py +0 -0
  172. viam/gen/component/button/v1/__init__.py +0 -0
  173. viam/gen/component/button/v1/button_grpc.py +38 -0
  174. viam/gen/component/button/v1/button_pb2.py +28 -0
  175. viam/gen/component/button/v1/button_pb2.pyi +39 -0
  176. viam/gen/component/camera/__init__.py +0 -0
  177. viam/gen/component/camera/v1/__init__.py +0 -0
  178. viam/gen/component/camera/v1/camera_grpc.py +79 -0
  179. viam/gen/component/camera/v1/camera_pb2.py +67 -0
  180. viam/gen/component/camera/v1/camera_pb2.pyi +373 -0
  181. viam/gen/component/encoder/__init__.py +0 -0
  182. viam/gen/component/encoder/v1/__init__.py +0 -0
  183. viam/gen/component/encoder/v1/encoder_grpc.py +62 -0
  184. viam/gen/component/encoder/v1/encoder_pb2.py +44 -0
  185. viam/gen/component/encoder/v1/encoder_pb2.pyi +147 -0
  186. viam/gen/component/gantry/__init__.py +0 -0
  187. viam/gen/component/gantry/v1/__init__.py +0 -0
  188. viam/gen/component/gantry/v1/gantry_grpc.py +86 -0
  189. viam/gen/component/gantry/v1/gantry_pb2.py +62 -0
  190. viam/gen/component/gantry/v1/gantry_pb2.pyi +239 -0
  191. viam/gen/component/generic/__init__.py +0 -0
  192. viam/gen/component/generic/v1/__init__.py +0 -0
  193. viam/gen/component/generic/v1/generic_grpc.py +37 -0
  194. viam/gen/component/generic/v1/generic_pb2.py +23 -0
  195. viam/gen/component/generic/v1/generic_pb2.pyi +6 -0
  196. viam/gen/component/gripper/__init__.py +0 -0
  197. viam/gen/component/gripper/v1/__init__.py +0 -0
  198. viam/gen/component/gripper/v1/gripper_grpc.py +70 -0
  199. viam/gen/component/gripper/v1/gripper_pb2.py +48 -0
  200. viam/gen/component/gripper/v1/gripper_pb2.pyi +137 -0
  201. viam/gen/component/inputcontroller/__init__.py +0 -0
  202. viam/gen/component/inputcontroller/v1/__init__.py +0 -0
  203. viam/gen/component/inputcontroller/v1/input_controller_grpc.py +71 -0
  204. viam/gen/component/inputcontroller/v1/input_controller_pb2.py +55 -0
  205. viam/gen/component/inputcontroller/v1/input_controller_pb2.pyi +243 -0
  206. viam/gen/component/motor/__init__.py +0 -0
  207. viam/gen/component/motor/v1/__init__.py +0 -0
  208. viam/gen/component/motor/v1/motor_grpc.py +118 -0
  209. viam/gen/component/motor/v1/motor_pb2.py +86 -0
  210. viam/gen/component/motor/v1/motor_pb2.pyi +368 -0
  211. viam/gen/component/movementsensor/__init__.py +0 -0
  212. viam/gen/component/movementsensor/v1/__init__.py +0 -0
  213. viam/gen/component/movementsensor/v1/movementsensor_grpc.py +110 -0
  214. viam/gen/component/movementsensor/v1/movementsensor_pb2.py +78 -0
  215. viam/gen/component/movementsensor/v1/movementsensor_pb2.pyi +384 -0
  216. viam/gen/component/posetracker/__init__.py +0 -0
  217. viam/gen/component/posetracker/v1/__init__.py +0 -0
  218. viam/gen/component/posetracker/v1/pose_tracker_grpc.py +46 -0
  219. viam/gen/component/posetracker/v1/pose_tracker_pb2.py +34 -0
  220. viam/gen/component/posetracker/v1/pose_tracker_pb2.pyi +79 -0
  221. viam/gen/component/powersensor/__init__.py +0 -0
  222. viam/gen/component/powersensor/v1/__init__.py +0 -0
  223. viam/gen/component/powersensor/v1/powersensor_grpc.py +62 -0
  224. viam/gen/component/powersensor/v1/powersensor_pb2.py +42 -0
  225. viam/gen/component/powersensor/v1/powersensor_pb2.pyi +124 -0
  226. viam/gen/component/sensor/__init__.py +0 -0
  227. viam/gen/component/sensor/v1/__init__.py +0 -0
  228. viam/gen/component/sensor/v1/sensor_grpc.py +45 -0
  229. viam/gen/component/sensor/v1/sensor_pb2.py +25 -0
  230. viam/gen/component/sensor/v1/sensor_pb2.pyi +6 -0
  231. viam/gen/component/servo/__init__.py +0 -0
  232. viam/gen/component/servo/v1/__init__.py +0 -0
  233. viam/gen/component/servo/v1/servo_grpc.py +70 -0
  234. viam/gen/component/servo/v1/servo_pb2.py +50 -0
  235. viam/gen/component/servo/v1/servo_pb2.pyi +150 -0
  236. viam/gen/component/switch/__init__.py +0 -0
  237. viam/gen/component/switch/v1/__init__.py +0 -0
  238. viam/gen/component/switch/v1/switch_grpc.py +54 -0
  239. viam/gen/component/switch/v1/switch_pb2.py +40 -0
  240. viam/gen/component/switch/v1/switch_pb2.pyi +109 -0
  241. viam/gen/component/testecho/__init__.py +0 -0
  242. viam/gen/component/testecho/v1/__init__.py +0 -0
  243. viam/gen/component/testecho/v1/testecho_grpc.py +52 -0
  244. viam/gen/component/testecho/v1/testecho_pb2.py +36 -0
  245. viam/gen/component/testecho/v1/testecho_pb2.pyi +114 -0
  246. viam/gen/module/__init__.py +0 -0
  247. viam/gen/module/v1/__init__.py +0 -0
  248. viam/gen/module/v1/module_grpc.py +61 -0
  249. viam/gen/module/v1/module_pb2.py +43 -0
  250. viam/gen/module/v1/module_pb2.pyi +211 -0
  251. viam/gen/proto/__init__.py +0 -0
  252. viam/gen/proto/rpc/__init__.py +0 -0
  253. viam/gen/proto/rpc/examples/__init__.py +0 -0
  254. viam/gen/proto/rpc/examples/echo/__init__.py +0 -0
  255. viam/gen/proto/rpc/examples/echo/v1/__init__.py +0 -0
  256. viam/gen/proto/rpc/examples/echo/v1/echo_grpc.py +44 -0
  257. viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +32 -0
  258. viam/gen/proto/rpc/examples/echo/v1/echo_pb2.pyi +87 -0
  259. viam/gen/proto/rpc/examples/echoresource/__init__.py +0 -0
  260. viam/gen/proto/rpc/examples/echoresource/v1/__init__.py +0 -0
  261. viam/gen/proto/rpc/examples/echoresource/v1/echoresource_grpc.py +43 -0
  262. viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +29 -0
  263. viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.pyi +93 -0
  264. viam/gen/proto/rpc/v1/__init__.py +0 -0
  265. viam/gen/proto/rpc/v1/auth_grpc.py +47 -0
  266. viam/gen/proto/rpc/v1/auth_pb2.py +34 -0
  267. viam/gen/proto/rpc/v1/auth_pb2.pyi +92 -0
  268. viam/gen/proto/rpc/webrtc/__init__.py +0 -0
  269. viam/gen/proto/rpc/webrtc/v1/__init__.py +0 -0
  270. viam/gen/proto/rpc/webrtc/v1/grpc_grpc.py +0 -0
  271. viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +43 -0
  272. viam/gen/proto/rpc/webrtc/v1/grpc_pb2.pyi +304 -0
  273. viam/gen/proto/rpc/webrtc/v1/signaling_grpc.py +54 -0
  274. viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +70 -0
  275. viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +496 -0
  276. viam/gen/provisioning/__init__.py +0 -0
  277. viam/gen/provisioning/v1/__init__.py +0 -0
  278. viam/gen/provisioning/v1/provisioning_grpc.py +51 -0
  279. viam/gen/provisioning/v1/provisioning_pb2.py +39 -0
  280. viam/gen/provisioning/v1/provisioning_pb2.pyi +188 -0
  281. viam/gen/robot/__init__.py +0 -0
  282. viam/gen/robot/v1/__init__.py +0 -0
  283. viam/gen/robot/v1/robot_grpc.py +208 -0
  284. viam/gen/robot/v1/robot_pb2.py +188 -0
  285. viam/gen/robot/v1/robot_pb2.pyi +1020 -0
  286. viam/gen/service/__init__.py +0 -0
  287. viam/gen/service/datamanager/__init__.py +0 -0
  288. viam/gen/service/datamanager/v1/__init__.py +0 -0
  289. viam/gen/service/datamanager/v1/data_manager_grpc.py +38 -0
  290. viam/gen/service/datamanager/v1/data_manager_pb2.py +28 -0
  291. viam/gen/service/datamanager/v1/data_manager_pb2.pyi +39 -0
  292. viam/gen/service/discovery/__init__.py +0 -0
  293. viam/gen/service/discovery/v1/__init__.py +0 -0
  294. viam/gen/service/discovery/v1/discovery_grpc.py +39 -0
  295. viam/gen/service/discovery/v1/discovery_pb2.py +29 -0
  296. viam/gen/service/discovery/v1/discovery_pb2.pyi +51 -0
  297. viam/gen/service/generic/__init__.py +0 -0
  298. viam/gen/service/generic/v1/__init__.py +0 -0
  299. viam/gen/service/generic/v1/generic_grpc.py +29 -0
  300. viam/gen/service/generic/v1/generic_pb2.py +21 -0
  301. viam/gen/service/generic/v1/generic_pb2.pyi +6 -0
  302. viam/gen/service/mlmodel/__init__.py +0 -0
  303. viam/gen/service/mlmodel/v1/__init__.py +0 -0
  304. viam/gen/service/mlmodel/v1/mlmodel_grpc.py +37 -0
  305. viam/gen/service/mlmodel/v1/mlmodel_pb2.py +83 -0
  306. viam/gen/service/mlmodel/v1/mlmodel_pb2.pyi +480 -0
  307. viam/gen/service/motion/__init__.py +0 -0
  308. viam/gen/service/motion/v1/__init__.py +0 -0
  309. viam/gen/service/motion/v1/motion_grpc.py +87 -0
  310. viam/gen/service/motion/v1/motion_pb2.py +97 -0
  311. viam/gen/service/motion/v1/motion_pb2.pyi +838 -0
  312. viam/gen/service/navigation/__init__.py +0 -0
  313. viam/gen/service/navigation/v1/__init__.py +0 -0
  314. viam/gen/service/navigation/v1/navigation_grpc.py +102 -0
  315. viam/gen/service/navigation/v1/navigation_pb2.py +84 -0
  316. viam/gen/service/navigation/v1/navigation_pb2.pyi +419 -0
  317. viam/gen/service/sensors/__init__.py +0 -0
  318. viam/gen/service/sensors/v1/__init__.py +0 -0
  319. viam/gen/service/sensors/v1/sensors_grpc.py +46 -0
  320. viam/gen/service/sensors/v1/sensors_pb2.py +68 -0
  321. viam/gen/service/sensors/v1/sensors_pb2.pyi +137 -0
  322. viam/gen/service/shell/__init__.py +0 -0
  323. viam/gen/service/shell/v1/__init__.py +0 -0
  324. viam/gen/service/shell/v1/shell_grpc.py +55 -0
  325. viam/gen/service/shell/v1/shell_pb2.py +45 -0
  326. viam/gen/service/shell/v1/shell_pb2.pyi +307 -0
  327. viam/gen/service/slam/__init__.py +0 -0
  328. viam/gen/service/slam/v1/__init__.py +0 -0
  329. viam/gen/service/slam/v1/slam_grpc.py +61 -0
  330. viam/gen/service/slam/v1/slam_pb2.py +51 -0
  331. viam/gen/service/slam/v1/slam_pb2.pyi +213 -0
  332. viam/gen/service/vision/__init__.py +0 -0
  333. viam/gen/service/vision/v1/__init__.py +0 -0
  334. viam/gen/service/vision/v1/vision_grpc.py +87 -0
  335. viam/gen/service/vision/v1/vision_pb2.py +69 -0
  336. viam/gen/service/vision/v1/vision_pb2.pyi +454 -0
  337. viam/gen/stream/__init__.py +0 -0
  338. viam/gen/stream/v1/__init__.py +0 -0
  339. viam/gen/stream/v1/stream_grpc.py +59 -0
  340. viam/gen/stream/v1/stream_pb2.py +39 -0
  341. viam/gen/stream/v1/stream_pb2.pyi +161 -0
  342. viam/gen/tagger/__init__.py +0 -0
  343. viam/gen/tagger/v1/__init__.py +0 -0
  344. viam/gen/tagger/v1/tagger_grpc.py +0 -0
  345. viam/gen/tagger/v1/tagger_pb2.py +16 -0
  346. viam/gen/tagger/v1/tagger_pb2.pyi +15 -0
  347. viam/logging.py +216 -0
  348. viam/media/__init__.py +0 -0
  349. viam/media/audio.py +16 -0
  350. viam/media/utils/__init__.py +0 -0
  351. viam/media/utils/pil/__init__.py +51 -0
  352. viam/media/utils/pil/viam_rgba_plugin.py +73 -0
  353. viam/media/viam_rgba.py +10 -0
  354. viam/media/video.py +217 -0
  355. viam/module/__init__.py +5 -0
  356. viam/module/module.py +281 -0
  357. viam/module/service.py +66 -0
  358. viam/module/types.py +23 -0
  359. viam/operations.py +124 -0
  360. viam/proto/__init__.py +0 -0
  361. viam/proto/app/__init__.py +554 -0
  362. viam/proto/app/agent/__init__.py +28 -0
  363. viam/proto/app/billing.py +58 -0
  364. viam/proto/app/cloudslam/__init__.py +48 -0
  365. viam/proto/app/data/__init__.py +138 -0
  366. viam/proto/app/datapipelines/__init__.py +56 -0
  367. viam/proto/app/dataset/__init__.py +36 -0
  368. viam/proto/app/datasync/__init__.py +44 -0
  369. viam/proto/app/end_user.py +34 -0
  370. viam/proto/app/mlinference/__init__.py +15 -0
  371. viam/proto/app/mltraining/__init__.py +52 -0
  372. viam/proto/app/packages/__init__.py +38 -0
  373. viam/proto/app/robot.py +84 -0
  374. viam/proto/common/__init__.py +66 -0
  375. viam/proto/component/__init__.py +0 -0
  376. viam/proto/component/arm/__init__.py +48 -0
  377. viam/proto/component/audioinput/__init__.py +30 -0
  378. viam/proto/component/base/__init__.py +42 -0
  379. viam/proto/component/board/__init__.py +62 -0
  380. viam/proto/component/button/__init__.py +15 -0
  381. viam/proto/component/camera/__init__.py +46 -0
  382. viam/proto/component/encoder/__init__.py +28 -0
  383. viam/proto/component/gantry/__init__.py +40 -0
  384. viam/proto/component/generic/__init__.py +12 -0
  385. viam/proto/component/gripper/__init__.py +30 -0
  386. viam/proto/component/inputcontroller/__init__.py +38 -0
  387. viam/proto/component/motor/__init__.py +56 -0
  388. viam/proto/component/movementsensor/__init__.py +50 -0
  389. viam/proto/component/posetracker/__init__.py +19 -0
  390. viam/proto/component/powersensor/__init__.py +30 -0
  391. viam/proto/component/sensor/__init__.py +12 -0
  392. viam/proto/component/servo/__init__.py +32 -0
  393. viam/proto/component/switch/__init__.py +26 -0
  394. viam/proto/component/testecho/__init__.py +30 -0
  395. viam/proto/module/__init__.py +38 -0
  396. viam/proto/provisioning/__init__.py +36 -0
  397. viam/proto/robot/__init__.py +130 -0
  398. viam/proto/rpc/__init__.py +0 -0
  399. viam/proto/rpc/auth.py +34 -0
  400. viam/proto/rpc/examples/__init__.py +0 -0
  401. viam/proto/rpc/examples/echo/__init__.py +26 -0
  402. viam/proto/rpc/examples/echoresource/__init__.py +30 -0
  403. viam/proto/rpc/webrtc/__init__.py +0 -0
  404. viam/proto/rpc/webrtc/grpc.py +36 -0
  405. viam/proto/rpc/webrtc/signaling.py +58 -0
  406. viam/proto/service/__init__.py +0 -0
  407. viam/proto/service/datamanager/__init__.py +19 -0
  408. viam/proto/service/discovery/__init__.py +15 -0
  409. viam/proto/service/generic/__init__.py +12 -0
  410. viam/proto/service/mlmodel/__init__.py +54 -0
  411. viam/proto/service/motion/__init__.py +68 -0
  412. viam/proto/service/navigation/__init__.py +58 -0
  413. viam/proto/service/sensors/__init__.py +18 -0
  414. viam/proto/service/shell/__init__.py +36 -0
  415. viam/proto/service/slam/__init__.py +36 -0
  416. viam/proto/service/vision/__init__.py +46 -0
  417. viam/proto/stream/__init__.py +36 -0
  418. viam/proto/tagger/__init__.py +6 -0
  419. viam/py.typed +0 -0
  420. viam/resource/__init__.py +0 -0
  421. viam/resource/base.py +123 -0
  422. viam/resource/easy_resource.py +153 -0
  423. viam/resource/manager.py +126 -0
  424. viam/resource/registry.py +199 -0
  425. viam/resource/rpc_client_base.py +65 -0
  426. viam/resource/rpc_service_base.py +48 -0
  427. viam/resource/types.py +213 -0
  428. viam/robot/__init__.py +0 -0
  429. viam/robot/client.py +909 -0
  430. viam/robot/service.py +69 -0
  431. viam/rpc/__init__.py +0 -0
  432. viam/rpc/dial.py +420 -0
  433. viam/rpc/libviam_rust_utils.dll +0 -0
  434. viam/rpc/server.py +201 -0
  435. viam/rpc/signaling.py +29 -0
  436. viam/rpc/types.py +22 -0
  437. viam/services/__init__.py +0 -0
  438. viam/services/discovery/__init__.py +12 -0
  439. viam/services/discovery/client.py +55 -0
  440. viam/services/discovery/discovery.py +52 -0
  441. viam/services/discovery/service.py +43 -0
  442. viam/services/generic/__init__.py +18 -0
  443. viam/services/generic/client.py +58 -0
  444. viam/services/generic/generic.py +58 -0
  445. viam/services/generic/service.py +29 -0
  446. viam/services/mlmodel/__init__.py +24 -0
  447. viam/services/mlmodel/client.py +37 -0
  448. viam/services/mlmodel/mlmodel.py +78 -0
  449. viam/services/mlmodel/service.py +38 -0
  450. viam/services/mlmodel/utils.py +101 -0
  451. viam/services/motion/__init__.py +17 -0
  452. viam/services/motion/client.py +215 -0
  453. viam/services/motion/motion.py +378 -0
  454. viam/services/motion/service.py +132 -0
  455. viam/services/navigation/__init__.py +11 -0
  456. viam/services/navigation/client.py +99 -0
  457. viam/services/navigation/navigation.py +250 -0
  458. viam/services/navigation/service.py +137 -0
  459. viam/services/service_base.py +78 -0
  460. viam/services/service_client_base.py +46 -0
  461. viam/services/slam/__init__.py +17 -0
  462. viam/services/slam/client.py +62 -0
  463. viam/services/slam/service.py +75 -0
  464. viam/services/slam/slam.py +111 -0
  465. viam/services/vision/__init__.py +15 -0
  466. viam/services/vision/client.py +206 -0
  467. viam/services/vision/service.py +146 -0
  468. viam/services/vision/vision.py +315 -0
  469. viam/sessions_client.py +245 -0
  470. viam/streams.py +44 -0
  471. viam/utils.py +365 -0
  472. viam/version_metadata.py +4 -0
  473. viam_sdk-0.45.2.dist-info/METADATA +157 -0
  474. viam_sdk-0.45.2.dist-info/RECORD +476 -0
  475. viam_sdk-0.45.2.dist-info/WHEEL +4 -0
  476. viam_sdk-0.45.2.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,199 @@
1
+ from dataclasses import dataclass
2
+ from threading import Lock
3
+ from typing import TYPE_CHECKING, Callable, ClassVar, Dict, Generic, Mapping, Type, TypeVar
4
+
5
+ from grpclib.client import Channel
6
+
7
+ from viam.errors import DuplicateResourceError, ResourceNotFoundError, ValidationError
8
+
9
+ from .base import ResourceBase
10
+
11
+ if TYPE_CHECKING:
12
+ from .rpc_service_base import ResourceRPCServiceBase
13
+ from .types import API, Model, ResourceCreator, Validator
14
+
15
+ Resource = TypeVar("Resource", bound=ResourceBase)
16
+
17
+
18
+ @dataclass
19
+ class ResourceCreatorRegistration:
20
+ """An object representing a resource creator to be registered.
21
+
22
+ If creating a custom Resource creator, you should register the creator by creating a ``ResourceCreatorRegistration`` object and
23
+ registering it to the ``Registry``.
24
+ """
25
+
26
+ creator: "ResourceCreator"
27
+ """A function that can create a resource given a mapping of dependencies (``ResourceName`` to ``ResourceBase``
28
+ """
29
+
30
+ validator: "Validator" = lambda x: []
31
+ """A function that can validate a resource and return implicit dependencies.
32
+
33
+ If called without a validator function, default to a function returning an empty Sequence
34
+ """
35
+
36
+
37
+ @dataclass
38
+ class ResourceRegistration(Generic[Resource]):
39
+ """An object representing a resource to be registered.
40
+
41
+ This object is generic over the ``ResourceBase``, and it includes various functionality for the resource,
42
+ such as creating its RPC client or status.
43
+
44
+ If creating a custom Resource type, you should register the resource by creating a ``ResourceRegistration`` object and registering it
45
+ to the ``Registry``.
46
+ """
47
+
48
+ resource_type: Type[Resource]
49
+ """The type of the Resource to be registered
50
+ """
51
+
52
+ rpc_service: Type["ResourceRPCServiceBase"]
53
+ """The type of the RPC service of the resource. This must extend from ``RPCServiceBase``
54
+ """
55
+
56
+ create_rpc_client: Callable[[str, Channel], Resource]
57
+ """A function that will create the RPC client for this resource
58
+ """
59
+
60
+
61
+ class Registry:
62
+ """The global registry of robotic parts.
63
+
64
+ **NB** The Registry should almost never be used directly
65
+
66
+ The Registry keeps track of the types of Resources that are available on robots using this SDK. All the base resource types are
67
+ pre-registered (for example Arm, Motor).
68
+
69
+ If you create a new resource type that is not an extension of any of the existing base resource types, then you must register said
70
+ resource using ``Registry.register(...)``.
71
+ """
72
+
73
+ _APIS: ClassVar[Dict["API", ResourceRegistration]] = {}
74
+ _RESOURCES: ClassVar[Dict[str, ResourceCreatorRegistration]] = {}
75
+ _lock: ClassVar[Lock] = Lock()
76
+
77
+ @classmethod
78
+ def register_api(cls, registration: ResourceRegistration[Resource]):
79
+ """Register a API with the Registry
80
+
81
+ Args:
82
+ registration (ResourceRegistration): Object containing registration data for the API
83
+
84
+ Raises:
85
+ DuplicateResourceError: Raised if the API to register is already in the registry
86
+ ValidationError: Raised if registration is missing any necessary parameters
87
+ """
88
+ with cls._lock:
89
+ if registration.resource_type.API in cls._APIS:
90
+ raise DuplicateResourceError(str(registration.resource_type.API))
91
+
92
+ if registration.resource_type and registration.rpc_service and registration.create_rpc_client:
93
+ cls._APIS[registration.resource_type.API] = registration
94
+ else:
95
+ raise ValidationError("Passed resource registration does not have correct parameters")
96
+
97
+ @classmethod
98
+ def register_resource_creator(cls, api: "API", model: "Model", registration: ResourceCreatorRegistration):
99
+ """Register a specific ``Model`` and validator function for the specific resource ``API`` with the Registry
100
+
101
+ Args:
102
+ api (API): The API of the resource
103
+ model (Model): The Model of the resource
104
+ registration (ResourceCreatorRegistration): The registration functions of the model
105
+
106
+ Raises:
107
+ DuplicateResourceError: Raised if the API and Model pairing is already registered
108
+ ValidationError: Raised if registration does not have creator
109
+ """
110
+ key = f"{api}/{model}"
111
+ with cls._lock:
112
+ if key in cls._RESOURCES:
113
+ raise DuplicateResourceError(key)
114
+
115
+ if registration.creator:
116
+ cls._RESOURCES[key] = registration
117
+ else:
118
+ raise ValidationError("A creator function was not provided")
119
+
120
+ @classmethod
121
+ def lookup_api(cls, api: "API") -> ResourceRegistration:
122
+ """Lookup and retrieve a registered API by its name
123
+
124
+ Args:
125
+ api (str): The API of the resource
126
+
127
+ Raises:
128
+ ResourceNotFoundError: Raised if the API is not registered
129
+
130
+ Returns:
131
+ ResourceRegistration: The registration object of the resource
132
+ """
133
+ with cls._lock:
134
+ try:
135
+ return cls._APIS[api]
136
+ except KeyError:
137
+ raise ResourceNotFoundError(api.resource_type, api.resource_subtype)
138
+
139
+ @classmethod
140
+ def lookup_resource_creator(cls, api: "API", model: "Model") -> "ResourceCreator":
141
+ """Lookup and retrieve a registered resource creator by its API and model
142
+
143
+ Args:
144
+ api (API): The API of the resource
145
+ model (Model): The Model of the resource
146
+
147
+ Raises:
148
+ ResourceNotFoundError: Raised if the API Model pairing is not registered
149
+
150
+ Returns:
151
+ ResourceCreator: The function to create the resource
152
+ """
153
+ with cls._lock:
154
+ try:
155
+ return cls._RESOURCES[f"{api}/{model}"].creator
156
+ except KeyError:
157
+ raise ResourceNotFoundError(api.resource_type, api.resource_subtype)
158
+
159
+ @classmethod
160
+ def lookup_validator(cls, api: "API", model: "Model") -> "Validator":
161
+ """Lookup and retrieve a registered validator function by its API and model. If there is none, return None
162
+
163
+ Args:
164
+ api (API): The API of the resource
165
+ model (Model): The Model of the resource
166
+
167
+ Returns:
168
+ Validator: The function to validate the resource
169
+ """
170
+ try:
171
+ return cls._RESOURCES[f"{api}/{model}"].validator
172
+ except AttributeError:
173
+ return lambda x: []
174
+ except KeyError:
175
+ raise ResourceNotFoundError(api.resource_type, api.resource_subtype)
176
+
177
+ @classmethod
178
+ def REGISTERED_APIS(cls) -> Mapping["API", ResourceRegistration]:
179
+ """The dictionary of all registered resources
180
+ - Key: API of the resource
181
+ - Value: The registration object for the resource
182
+
183
+ Returns:
184
+ Mapping[API, ResourceRegistration]: All registered resources
185
+ """
186
+ with cls._lock:
187
+ return cls._APIS.copy()
188
+
189
+ @classmethod
190
+ def REGISTERED_RESOURCE_CREATORS(cls) -> Mapping[str, "ResourceCreatorRegistration"]:
191
+ """The dictionary of all registered resources
192
+ - Key: API/model
193
+ - Value: The ResourceCreatorRegistration for the resource
194
+
195
+ Returns:
196
+ Mapping[str, ResourceCreatorRegistration]: All registered resources
197
+ """
198
+ with cls._lock:
199
+ return cls._RESOURCES.copy()
@@ -0,0 +1,65 @@
1
+ from random import choice
2
+ from string import ascii_lowercase
3
+ from typing import Any, Dict, Protocol, runtime_checkable
4
+
5
+ from grpclib.client import Channel
6
+
7
+ from viam.rpc.types import RPCServiceStubBase
8
+
9
+
10
+ @runtime_checkable
11
+ class ResourceRPCClientBase(Protocol):
12
+ """
13
+ Base RPC client for a resource.
14
+ Resource RPC clients must inherit from this class
15
+ """
16
+
17
+ class Metadata:
18
+ metadata: Dict[str, str] = {}
19
+
20
+ def enable_debug_logging(self, key: str = ""):
21
+ """Enables server-side debug logging for resource methods.
22
+
23
+ Args:
24
+ key (str): The key to associate debug logs with. If not provided, will default to a randomly generated string value.
25
+ """
26
+ if key == "":
27
+ key = "".join(choice(ascii_lowercase) for i in range(6))
28
+ self.metadata["dtname"] = key
29
+
30
+ def disable_debug_logging(self):
31
+ """Disables server-side debug logging for resource methods."""
32
+ del self.metadata["dtname"]
33
+
34
+ def add_metadata(self, key: str, value: str):
35
+ """Adds a key-value pair to the metadata"""
36
+ self.metadata[key] = value
37
+
38
+ def delete_metadata(self, key: str):
39
+ """Removes a key-value pair from the metadata by key"""
40
+ del self.metadata[key]
41
+
42
+ @property
43
+ def proto(self):
44
+ """Returns metadata in a gRPC-appropriate form"""
45
+ return [(k, v) for k, v in self.metadata.items()]
46
+
47
+ channel: Channel
48
+ client: Any
49
+
50
+
51
+ class ReconfigurableResourceRPCClientBase(ResourceRPCClientBase):
52
+ """A base RPC client that can reset its channel.
53
+
54
+ Useful if connection is lost and then regained.
55
+ """
56
+
57
+ def reset_channel(self, channel: Channel):
58
+ """Called when the RPC channel was reset. Passes in the new channel.
59
+
60
+ Args:
61
+ channel (Channel): The new RPC Channel
62
+ """
63
+ self.channel = channel
64
+ if isinstance(self.client, RPCServiceStubBase):
65
+ self.client = self.client.__class__(channel)
@@ -0,0 +1,48 @@
1
+ import abc
2
+ from typing import TYPE_CHECKING, Generic, Type
3
+
4
+ from viam.components.component_base import ComponentBase
5
+ from viam.errors import ResourceNotFoundError
6
+ from viam.resource.manager import ResourceType
7
+ from viam.rpc.types import RPCServiceBase
8
+ from viam.services.service_base import ServiceBase
9
+
10
+ from .base import ResourceBase
11
+
12
+ if TYPE_CHECKING:
13
+ from viam.resource.manager import ResourceManager
14
+
15
+
16
+ class ResourceRPCServiceBase(abc.ABC, RPCServiceBase, Generic[ResourceType]):
17
+ """
18
+ Base RPC service for a resource.
19
+ All resource RPC services must inherit from this class.
20
+ """
21
+
22
+ RESOURCE_TYPE = Type
23
+ manager: "ResourceManager"
24
+
25
+ def __init__(self, manager: "ResourceManager"):
26
+ self.manager = manager
27
+
28
+ def get_resource(self, name: str) -> ResourceType:
29
+ """
30
+ Return the resource with the given name if it exists in the registry.
31
+ If the resource does not exist in the registry,
32
+ this function will raise an error
33
+
34
+ Args:
35
+ name (str): Name of the resource
36
+
37
+ Raises:
38
+ GRPCError with the status code Status.NOT_FOUND
39
+
40
+ Returns:
41
+ ResourceType: The resource
42
+ """
43
+ try:
44
+ if self.RESOURCE_TYPE == ComponentBase or self.RESOURCE_TYPE == ResourceBase or self.RESOURCE_TYPE == ServiceBase:
45
+ return self.manager._resource_by_name_only(name) # type: ignore
46
+ return self.manager.get_resource(self.RESOURCE_TYPE, self.RESOURCE_TYPE.get_resource_name(name)) # type: ignore
47
+ except ResourceNotFoundError as e:
48
+ raise e.grpc_error
viam/resource/types.py ADDED
@@ -0,0 +1,213 @@
1
+ import re
2
+ import sys
3
+ from typing import TYPE_CHECKING, Callable, ClassVar, Mapping, Optional, Protocol, Sequence, runtime_checkable
4
+
5
+ if sys.version_info >= (3, 10):
6
+ from typing import TypeAlias
7
+ else:
8
+ from typing_extensions import TypeAlias
9
+
10
+ from typing_extensions import Self
11
+
12
+ from viam.proto.app.robot import ComponentConfig
13
+ from viam.proto.common import GetGeometriesRequest, GetGeometriesResponse, ResourceName
14
+
15
+ if TYPE_CHECKING:
16
+ from .base import ResourceBase
17
+
18
+ RESOURCE_NAMESPACE_RDK = "rdk"
19
+ RESOURCE_TYPE_COMPONENT = "component"
20
+ RESOURCE_TYPE_SERVICE = "service"
21
+
22
+
23
+ class API:
24
+ """Represents a known component/service (resource) API"""
25
+
26
+ namespace: str
27
+ """The namespace of the resource"""
28
+
29
+ resource_type: str
30
+ """The type of the resource, for example `component` or `service`"""
31
+
32
+ resource_subtype: str
33
+ """The subtype of the resource for example `servo`, `arm`, `vision`"""
34
+
35
+ def __init__(self, namespace: str, resource_type: str, resource_subtype: str):
36
+ self.namespace = namespace
37
+ self.resource_type = resource_type
38
+ self.resource_subtype = resource_subtype
39
+
40
+ def __str__(self) -> str:
41
+ return f"{self.namespace}:{self.resource_type}:{self.resource_subtype}"
42
+
43
+ def __repr__(self) -> str:
44
+ return f"<viam.resource.types.API {str(self)} at {hex(id(self))}>"
45
+
46
+ def __hash__(self) -> int:
47
+ return hash(str(self))
48
+
49
+ def __eq__(self, other: object) -> bool:
50
+ if isinstance(other, API):
51
+ return str(self) == str(other)
52
+ return False
53
+
54
+ @classmethod
55
+ def from_resource_name(cls, resource_name: ResourceName) -> Self:
56
+ """Convert a ```ResourceName``` into a ```API```
57
+
58
+ Args:
59
+ resource_name (viam.proto.common.ResourceName): The ResourceName to convert
60
+
61
+ Returns:
62
+ Self: A new API
63
+ """
64
+ return cls(resource_name.namespace, resource_name.type, resource_name.subtype)
65
+
66
+ @classmethod
67
+ def from_string(cls, string: str) -> Self:
68
+ """Create a ```API``` from its string representation (namespace:resource_type:resource_subtype)
69
+
70
+ Args:
71
+ string (str): The API as a string
72
+
73
+ Raises:
74
+ ValueError: Raised if the string does not represent a valid API
75
+
76
+ Returns:
77
+ Self: A new API
78
+ """
79
+ regex = re.compile(r"^([\w-]+):([\w-]+):([\w-]+)$")
80
+ match = regex.match(string)
81
+ if not match:
82
+ raise ValueError(f"{string} is not a valid API")
83
+ return cls(match.group(1), match.group(2), match.group(3))
84
+
85
+
86
+ class ModelFamily:
87
+ """Represents a family of related models"""
88
+
89
+ namespace: str
90
+ """The namespace of the model family"""
91
+
92
+ family: str
93
+ """The family name"""
94
+
95
+ DEFAULT_FAMILY_NAME: ClassVar[str] = "builtin"
96
+
97
+ DEFAULT: ClassVar["ModelFamily"]
98
+
99
+ def __init__(self, namespace: str, family: str):
100
+ self.namespace = namespace
101
+ self.family = family
102
+
103
+ def __str__(self) -> str:
104
+ return f"{self.namespace}:{self.family}"
105
+
106
+ def __repr__(self) -> str:
107
+ return f"<viam.resource.types.ModelFamily {str(self)} at {hex(id(self))}>"
108
+
109
+ def __hash__(self) -> int:
110
+ return hash(str(self))
111
+
112
+ def __eq__(self, other: object) -> bool:
113
+ if isinstance(other, ModelFamily):
114
+ return str(self) == str(other)
115
+ return False
116
+
117
+
118
+ ModelFamily.DEFAULT = ModelFamily(RESOURCE_NAMESPACE_RDK, ModelFamily.DEFAULT_FAMILY_NAME)
119
+
120
+
121
+ class Model:
122
+ """Represents a specific model within a family of models"""
123
+
124
+ model_family: ModelFamily
125
+ """The family to which this model belongs"""
126
+
127
+ name: str
128
+ """The name of the model"""
129
+
130
+ def __init__(self, model_family: ModelFamily, name: str):
131
+ self.model_family = model_family
132
+ self.name = name
133
+
134
+ def __str__(self) -> str:
135
+ return f"{self.model_family}:{self.name}"
136
+
137
+ def __repr__(self) -> str:
138
+ return f"<viam.resource.types.Model {str(self)} at {hex(id(self))}>"
139
+
140
+ def __hash__(self) -> int:
141
+ return hash(str(self))
142
+
143
+ def __eq__(self, other: object) -> bool:
144
+ if isinstance(other, Model):
145
+ return str(self) == str(other)
146
+ return False
147
+
148
+ @classmethod
149
+ def from_string(cls, model: str, *, ignore_errors=False) -> Self:
150
+ """Create a ```Model``` from its string representation (namespace:family:name).
151
+
152
+ Args:
153
+ model (str): The Model as a string
154
+ ignore_errors (bool, optional): If namespace or family are not found in the string, default to empty string
155
+ rather than raise an exception. Defaults to False.
156
+
157
+ Raises:
158
+ ValueError: Raised if the provided string is not a valid Model
159
+
160
+ Returns:
161
+ Self: The Model
162
+ """
163
+ regex = re.compile(r"^([\w-]+):([\w-]+):([\w-]+)$")
164
+ match = regex.match(model)
165
+ if match:
166
+ namespace = match.group(1)
167
+ family = match.group(2)
168
+ name = match.group(3)
169
+ model_family = ModelFamily(namespace, family)
170
+ elif ignore_errors:
171
+ model_family = ModelFamily("", "")
172
+ name = model
173
+ else:
174
+ raise ValueError(f"{model} is not a valid Model")
175
+
176
+ return cls(model_family, name)
177
+
178
+
179
+ def resource_name_from_string(string: str) -> ResourceName:
180
+ """Create a ResourceName from its string representation (namespace:resource_type:resource_subtype/<optional_remote:>name)
181
+
182
+ Args:
183
+ string (str): The ResourceName as a string
184
+
185
+ Raises:
186
+ ValueError: Raised if the provided string is not a valid ResourceName
187
+
188
+ Returns:
189
+ viam.proto.common.ResourceName: The new ResourceName
190
+ """
191
+ regex = re.compile(r"^([\w-]+:[\w-]+:(?:[\w-]+))\/?([\w-]+:(?:[\w-]+:)*)?(.+)?$")
192
+ match = regex.match(string)
193
+ if not match:
194
+ raise ValueError(f"{string} is not a valid ResourceName")
195
+ parts = match[1].split(":")
196
+ if len(parts) != 3:
197
+ raise ValueError(f"{string} is not a valid ResourceName")
198
+ if match[2]:
199
+ name = f"{match[2]}{match[3]}"
200
+ else:
201
+ name = match[3]
202
+ return ResourceName(namespace=parts[0], type=parts[1], subtype=parts[2], name=name)
203
+
204
+
205
+ ResourceCreator: TypeAlias = Callable[[ComponentConfig, Mapping[ResourceName, "ResourceBase"]], "ResourceBase"]
206
+ Validator: TypeAlias = Callable[[ComponentConfig], Sequence[str]]
207
+
208
+
209
+ @runtime_checkable
210
+ class SupportsGetGeometries(Protocol):
211
+ """The SupportsGetGeometries protocol defines the requirements for a resource to call get_geometries."""
212
+
213
+ async def GetGeometries(self, request: GetGeometriesRequest, *, timeout: Optional[float] = None, **kwargs) -> GetGeometriesResponse: ...
viam/robot/__init__.py ADDED
File without changes