viam-sdk 0.25.2__py3-none-linux_armv7l.whl → 0.62.0__py3-none-linux_armv7l.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.
Files changed (328) hide show
  1. viam/app/_logs.py +3 -6
  2. viam/app/app_client.py +606 -262
  3. viam/app/billing_client.py +60 -18
  4. viam/app/data_client.py +1086 -315
  5. viam/app/ml_training_client.py +51 -48
  6. viam/app/provisioning_client.py +3 -5
  7. viam/app/viam_client.py +105 -11
  8. viam/components/arm/__init__.py +1 -25
  9. viam/components/arm/arm.py +21 -22
  10. viam/components/arm/client.py +27 -30
  11. viam/components/arm/service.py +3 -3
  12. viam/components/audio_in/__init__.py +24 -0
  13. viam/components/audio_in/audio_in.py +74 -0
  14. viam/components/audio_in/client.py +76 -0
  15. viam/components/audio_in/service.py +83 -0
  16. viam/components/audio_input/__init__.py +1 -1
  17. viam/components/audio_input/audio_input.py +4 -3
  18. viam/components/audio_input/client.py +19 -8
  19. viam/components/audio_input/service.py +10 -0
  20. viam/components/audio_out/__init__.py +21 -0
  21. viam/components/audio_out/audio_out.py +72 -0
  22. viam/components/audio_out/client.py +67 -0
  23. viam/components/audio_out/service.py +63 -0
  24. viam/components/base/__init__.py +2 -10
  25. viam/components/base/base.py +20 -20
  26. viam/components/base/client.py +27 -30
  27. viam/components/board/__init__.py +2 -25
  28. viam/components/board/board.py +39 -77
  29. viam/components/board/client.py +39 -73
  30. viam/components/button/__init__.py +10 -0
  31. viam/components/button/button.py +41 -0
  32. viam/components/button/client.py +52 -0
  33. viam/components/button/service.py +46 -0
  34. viam/components/camera/__init__.py +1 -1
  35. viam/components/camera/camera.py +31 -22
  36. viam/components/camera/client.py +30 -20
  37. viam/components/camera/service.py +14 -12
  38. viam/components/component_base.py +10 -7
  39. viam/components/encoder/__init__.py +1 -1
  40. viam/components/encoder/client.py +15 -16
  41. viam/components/encoder/encoder.py +9 -9
  42. viam/components/gantry/__init__.py +1 -13
  43. viam/components/gantry/client.py +41 -28
  44. viam/components/gantry/gantry.py +48 -17
  45. viam/components/gantry/service.py +21 -5
  46. viam/components/generic/__init__.py +1 -1
  47. viam/components/generic/client.py +11 -7
  48. viam/components/generic/generic.py +3 -3
  49. viam/components/gripper/__init__.py +3 -12
  50. viam/components/gripper/client.py +43 -20
  51. viam/components/gripper/gripper.py +87 -12
  52. viam/components/gripper/service.py +32 -3
  53. viam/components/input/__init__.py +1 -14
  54. viam/components/input/client.py +22 -23
  55. viam/components/input/input.py +18 -12
  56. viam/components/motor/__init__.py +1 -21
  57. viam/components/motor/client.py +36 -42
  58. viam/components/motor/motor.py +24 -24
  59. viam/components/movement_sensor/__init__.py +1 -1
  60. viam/components/movement_sensor/client.py +33 -40
  61. viam/components/movement_sensor/movement_sensor.py +12 -12
  62. viam/components/pose_tracker/__init__.py +1 -1
  63. viam/components/pose_tracker/client.py +9 -8
  64. viam/components/pose_tracker/pose_tracker.py +2 -2
  65. viam/components/power_sensor/__init__.py +1 -1
  66. viam/components/power_sensor/client.py +15 -18
  67. viam/components/power_sensor/power_sensor.py +12 -12
  68. viam/components/sensor/__init__.py +1 -1
  69. viam/components/sensor/client.py +9 -8
  70. viam/components/sensor/sensor.py +5 -5
  71. viam/components/servo/__init__.py +1 -13
  72. viam/components/servo/client.py +18 -18
  73. viam/components/servo/servo.py +12 -12
  74. viam/components/switch/__init__.py +10 -0
  75. viam/components/switch/client.py +83 -0
  76. viam/components/switch/service.py +72 -0
  77. viam/components/switch/switch.py +95 -0
  78. viam/gen/app/agent/v1/agent_pb2.py +40 -29
  79. viam/gen/app/agent/v1/agent_pb2.pyi +73 -11
  80. viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +45 -42
  81. viam/gen/app/data/v1/data_grpc.py +98 -2
  82. viam/gen/app/data/v1/data_pb2.py +238 -119
  83. viam/gen/app/data/v1/data_pb2.pyi +804 -34
  84. viam/gen/app/datapipelines/v1/data_pipelines_grpc.py +84 -0
  85. viam/gen/app/datapipelines/v1/data_pipelines_pb2.py +57 -0
  86. viam/gen/app/datapipelines/v1/data_pipelines_pb2.pyi +387 -0
  87. viam/gen/app/dataset/v1/dataset_grpc.py +10 -2
  88. viam/gen/app/dataset/v1/dataset_pb2.py +38 -31
  89. viam/gen/app/dataset/v1/dataset_pb2.pyi +36 -1
  90. viam/gen/app/datasync/v1/data_sync_grpc.py +1 -1
  91. viam/gen/app/datasync/v1/data_sync_pb2.py +61 -51
  92. viam/gen/app/datasync/v1/data_sync_pb2.pyi +52 -12
  93. viam/gen/app/mlinference/__init__.py +0 -0
  94. viam/gen/app/mlinference/v1/__init__.py +0 -0
  95. viam/gen/app/mlinference/v1/ml_inference_grpc.py +28 -0
  96. viam/gen/app/mlinference/v1/ml_inference_pb2.py +23 -0
  97. viam/gen/app/mlinference/v1/ml_inference_pb2.pyi +63 -0
  98. viam/gen/app/mltraining/v1/ml_training_grpc.py +18 -2
  99. viam/gen/app/mltraining/v1/ml_training_pb2.py +134 -101
  100. viam/gen/app/mltraining/v1/ml_training_pb2.pyi +193 -7
  101. viam/gen/app/packages/v1/packages_pb2.py +43 -40
  102. viam/gen/app/v1/app_grpc.py +290 -2
  103. viam/gen/app/v1/app_pb2.py +670 -453
  104. viam/gen/app/v1/app_pb2.pyi +3133 -947
  105. viam/gen/app/v1/billing_grpc.py +34 -2
  106. viam/gen/app/v1/billing_pb2.py +94 -35
  107. viam/gen/app/v1/billing_pb2.pyi +314 -61
  108. viam/gen/app/v1/end_user_pb2.py +50 -29
  109. viam/gen/app/v1/robot_pb2.py +120 -111
  110. viam/gen/app/v1/robot_pb2.pyi +137 -15
  111. viam/gen/common/v1/common_pb2.py +86 -66
  112. viam/gen/common/v1/common_pb2.pyi +184 -8
  113. viam/gen/component/arm/v1/arm_grpc.py +18 -2
  114. viam/gen/component/arm/v1/arm_pb2.py +68 -55
  115. viam/gen/component/arm/v1/arm_pb2.pyi +73 -3
  116. viam/gen/component/audioin/__init__.py +0 -0
  117. viam/gen/component/audioin/v1/__init__.py +0 -0
  118. viam/gen/component/audioin/v1/audioin_grpc.py +54 -0
  119. viam/gen/component/audioin/v1/audioin_pb2.py +34 -0
  120. viam/gen/component/audioin/v1/audioin_pb2.pyi +94 -0
  121. viam/gen/component/audioinput/v1/audioinput_pb2.py +35 -32
  122. viam/gen/component/audioout/__init__.py +0 -0
  123. viam/gen/component/audioout/v1/__init__.py +0 -0
  124. viam/gen/component/audioout/v1/audioout_grpc.py +54 -0
  125. viam/gen/component/audioout/v1/audioout_pb2.py +32 -0
  126. viam/gen/component/audioout/v1/audioout_pb2.pyi +47 -0
  127. viam/gen/component/base/v1/base_pb2.py +57 -54
  128. viam/gen/component/board/v1/board_pb2.py +93 -90
  129. viam/gen/component/button/__init__.py +0 -0
  130. viam/gen/component/button/v1/__init__.py +0 -0
  131. viam/gen/component/button/v1/button_grpc.py +38 -0
  132. viam/gen/component/button/v1/button_pb2.py +28 -0
  133. viam/gen/component/button/v1/button_pb2.pyi +39 -0
  134. viam/gen/component/camera/v1/camera_pb2.py +58 -55
  135. viam/gen/component/camera/v1/camera_pb2.pyi +31 -7
  136. viam/gen/component/encoder/v1/encoder_pb2.py +35 -32
  137. viam/gen/component/gantry/v1/gantry_grpc.py +9 -1
  138. viam/gen/component/gantry/v1/gantry_pb2.py +56 -51
  139. viam/gen/component/generic/v1/generic_pb2.py +15 -12
  140. viam/gen/component/gripper/v1/gripper_grpc.py +18 -2
  141. viam/gen/component/gripper/v1/gripper_pb2.py +48 -37
  142. viam/gen/component/gripper/v1/gripper_pb2.pyi +43 -1
  143. viam/gen/component/inputcontroller/v1/input_controller_pb2.py +45 -42
  144. viam/gen/component/motor/v1/motor_pb2.py +77 -74
  145. viam/gen/component/movementsensor/v1/movementsensor_pb2.py +69 -66
  146. viam/gen/component/posetracker/v1/pose_tracker_pb2.py +25 -22
  147. viam/gen/component/powersensor/v1/powersensor_pb2.py +33 -30
  148. viam/gen/component/sensor/v1/sensor_pb2.py +17 -14
  149. viam/gen/component/servo/v1/servo_pb2.py +41 -38
  150. viam/gen/component/switch/__init__.py +0 -0
  151. viam/gen/component/switch/v1/__init__.py +0 -0
  152. viam/gen/component/switch/v1/switch_grpc.py +54 -0
  153. viam/gen/component/switch/v1/switch_pb2.py +40 -0
  154. viam/gen/component/switch/v1/switch_pb2.pyi +116 -0
  155. viam/gen/component/testecho/v1/testecho_pb2.py +29 -26
  156. viam/gen/module/v1/module_pb2.py +36 -33
  157. viam/gen/module/v1/module_pb2.pyi +7 -2
  158. viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +26 -23
  159. viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +23 -20
  160. viam/gen/proto/rpc/v1/auth_pb2.py +27 -24
  161. viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +35 -32
  162. viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +62 -57
  163. viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +18 -4
  164. viam/gen/provisioning/v1/provisioning_grpc.py +10 -2
  165. viam/gen/provisioning/v1/provisioning_pb2.py +38 -31
  166. viam/gen/provisioning/v1/provisioning_pb2.pyi +20 -2
  167. viam/gen/robot/v1/robot_grpc.py +61 -29
  168. viam/gen/robot/v1/robot_pb2.py +186 -155
  169. viam/gen/robot/v1/robot_pb2.pyi +278 -59
  170. viam/gen/service/datamanager/v1/data_manager_grpc.py +11 -2
  171. viam/gen/service/datamanager/v1/data_manager_pb2.py +27 -17
  172. viam/gen/service/datamanager/v1/data_manager_pb2.pyi +47 -1
  173. viam/gen/service/discovery/__init__.py +0 -0
  174. viam/gen/service/discovery/v1/__init__.py +0 -0
  175. viam/gen/service/discovery/v1/discovery_grpc.py +39 -0
  176. viam/gen/service/discovery/v1/discovery_pb2.py +29 -0
  177. viam/gen/service/discovery/v1/discovery_pb2.pyi +51 -0
  178. viam/gen/service/generic/v1/generic_pb2.py +13 -10
  179. viam/gen/service/mlmodel/v1/mlmodel_pb2.py +75 -72
  180. viam/gen/service/motion/v1/motion_pb2.py +118 -85
  181. viam/gen/service/motion/v1/motion_pb2.pyi +130 -68
  182. viam/gen/service/navigation/v1/navigation_pb2.py +75 -72
  183. viam/gen/service/sensors/v1/sensors_pb2.py +59 -56
  184. viam/gen/service/shell/v1/shell_pb2.py +35 -32
  185. viam/gen/service/slam/v1/slam_pb2.py +43 -40
  186. viam/gen/service/slam/v1/slam_pb2.pyi +1 -1
  187. viam/gen/service/video/__init__.py +0 -0
  188. viam/gen/service/video/v1/__init__.py +0 -0
  189. viam/gen/service/video/v1/video_grpc.py +39 -0
  190. viam/gen/service/video/v1/video_pb2.py +29 -0
  191. viam/gen/service/video/v1/video_pb2.pyi +72 -0
  192. viam/gen/service/vision/v1/vision_pb2.py +60 -57
  193. viam/gen/service/vision/v1/vision_pb2.pyi +28 -3
  194. viam/gen/service/worldstatestore/__init__.py +0 -0
  195. viam/gen/service/worldstatestore/v1/__init__.py +0 -0
  196. viam/gen/service/worldstatestore/v1/world_state_store_grpc.py +55 -0
  197. viam/gen/service/worldstatestore/v1/world_state_store_pb2.py +39 -0
  198. viam/gen/service/worldstatestore/v1/world_state_store_pb2.pyi +171 -0
  199. viam/gen/stream/v1/stream_grpc.py +17 -1
  200. viam/gen/stream/v1/stream_pb2.py +34 -21
  201. viam/gen/stream/v1/stream_pb2.pyi +79 -1
  202. viam/gen/tagger/v1/tagger_pb2.py +9 -8
  203. viam/logging.py +77 -18
  204. viam/media/audio.py +28 -0
  205. viam/media/utils/pil/__init__.py +7 -3
  206. viam/media/video.py +80 -17
  207. viam/module/module.py +111 -38
  208. viam/module/resource_data_consumer.py +41 -0
  209. viam/module/service.py +9 -1
  210. viam/module/types.py +2 -4
  211. viam/proto/app/__init__.py +199 -0
  212. viam/proto/app/agent/__init__.py +5 -2
  213. viam/proto/app/billing.py +31 -4
  214. viam/proto/app/cloudslam/__init__.py +1 -0
  215. viam/proto/app/data/__init__.py +63 -0
  216. viam/proto/app/datapipelines/__init__.py +56 -0
  217. viam/proto/app/dataset/__init__.py +5 -0
  218. viam/proto/app/datasync/__init__.py +3 -0
  219. viam/proto/app/end_user.py +1 -0
  220. viam/proto/app/mlinference/__init__.py +15 -0
  221. viam/proto/app/mltraining/__init__.py +13 -0
  222. viam/proto/app/packages/__init__.py +1 -0
  223. viam/proto/app/robot.py +7 -0
  224. viam/proto/common/__init__.py +15 -0
  225. viam/proto/component/arm/__init__.py +7 -0
  226. viam/proto/component/audioin/__init__.py +16 -0
  227. viam/proto/component/audioinput/__init__.py +1 -0
  228. viam/proto/component/audioout/__init__.py +15 -0
  229. viam/proto/component/base/__init__.py +1 -0
  230. viam/proto/component/board/__init__.py +1 -0
  231. viam/proto/component/button/__init__.py +15 -0
  232. viam/proto/component/camera/__init__.py +1 -0
  233. viam/proto/component/encoder/__init__.py +1 -0
  234. viam/proto/component/gantry/__init__.py +1 -0
  235. viam/proto/component/generic/__init__.py +1 -0
  236. viam/proto/component/gripper/__init__.py +5 -0
  237. viam/proto/component/inputcontroller/__init__.py +1 -0
  238. viam/proto/component/motor/__init__.py +1 -0
  239. viam/proto/component/movementsensor/__init__.py +1 -0
  240. viam/proto/component/posetracker/__init__.py +1 -0
  241. viam/proto/component/powersensor/__init__.py +1 -0
  242. viam/proto/component/sensor/__init__.py +1 -0
  243. viam/proto/component/servo/__init__.py +1 -0
  244. viam/proto/component/switch/__init__.py +26 -0
  245. viam/proto/component/testecho/__init__.py +1 -0
  246. viam/proto/module/__init__.py +1 -0
  247. viam/proto/provisioning/__init__.py +5 -0
  248. viam/proto/robot/__init__.py +29 -8
  249. viam/proto/rpc/auth.py +1 -0
  250. viam/proto/rpc/examples/echo/__init__.py +1 -0
  251. viam/proto/rpc/examples/echoresource/__init__.py +1 -0
  252. viam/proto/rpc/webrtc/grpc.py +1 -0
  253. viam/proto/rpc/webrtc/signaling.py +3 -0
  254. viam/proto/service/datamanager/__init__.py +9 -1
  255. viam/proto/service/discovery/__init__.py +15 -0
  256. viam/proto/service/generic/__init__.py +1 -0
  257. viam/proto/service/mlmodel/__init__.py +1 -0
  258. viam/proto/service/motion/__init__.py +3 -0
  259. viam/proto/service/navigation/__init__.py +1 -0
  260. viam/proto/service/sensors/__init__.py +1 -0
  261. viam/proto/service/shell/__init__.py +1 -0
  262. viam/proto/service/slam/__init__.py +1 -0
  263. viam/proto/service/video/__init__.py +15 -0
  264. viam/proto/service/vision/__init__.py +1 -0
  265. viam/proto/service/worldstatestore/__init__.py +32 -0
  266. viam/proto/stream/__init__.py +11 -0
  267. viam/py.typed +0 -0
  268. viam/resource/base.py +12 -8
  269. viam/resource/easy_resource.py +24 -13
  270. viam/resource/manager.py +6 -5
  271. viam/resource/registry.py +39 -51
  272. viam/resource/rpc_client_base.py +33 -1
  273. viam/resource/types.py +13 -14
  274. viam/robot/client.py +190 -122
  275. viam/robot/service.py +2 -50
  276. viam/rpc/dial.py +54 -4
  277. viam/rpc/libviam_rust_utils.so +0 -0
  278. viam/rpc/server.py +25 -11
  279. viam/rpc/types.py +2 -4
  280. viam/services/discovery/__init__.py +12 -0
  281. viam/services/discovery/client.py +55 -0
  282. viam/services/discovery/discovery.py +52 -0
  283. viam/services/discovery/service.py +43 -0
  284. viam/services/generic/__init__.py +1 -1
  285. viam/services/generic/client.py +8 -5
  286. viam/services/generic/generic.py +2 -2
  287. viam/services/mlmodel/__init__.py +1 -1
  288. viam/services/mlmodel/client.py +17 -7
  289. viam/services/mlmodel/mlmodel.py +23 -12
  290. viam/services/mlmodel/service.py +5 -2
  291. viam/services/mlmodel/utils.py +11 -1
  292. viam/services/motion/__init__.py +2 -2
  293. viam/services/motion/client.py +32 -32
  294. viam/services/motion/motion.py +66 -62
  295. viam/services/navigation/__init__.py +1 -1
  296. viam/services/navigation/client.py +30 -20
  297. viam/services/navigation/navigation.py +23 -23
  298. viam/services/service_base.py +13 -9
  299. viam/services/service_client_base.py +3 -3
  300. viam/services/slam/__init__.py +1 -1
  301. viam/services/slam/client.py +15 -10
  302. viam/services/slam/slam.py +11 -11
  303. viam/services/vision/__init__.py +1 -1
  304. viam/services/vision/client.py +31 -24
  305. viam/services/vision/service.py +8 -8
  306. viam/services/vision/vision.py +36 -53
  307. viam/services/worldstatestore/__init__.py +18 -0
  308. viam/services/worldstatestore/client.py +94 -0
  309. viam/services/worldstatestore/service.py +55 -0
  310. viam/services/worldstatestore/worldstatestore.py +90 -0
  311. viam/sessions_client.py +115 -46
  312. viam/streams.py +3 -6
  313. viam/utils.py +44 -14
  314. viam/version_metadata.py +4 -0
  315. {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/METADATA +27 -28
  316. viam_sdk-0.62.0.dist-info/RECORD +514 -0
  317. {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/WHEEL +1 -1
  318. viam/gen/proto/rpc/examples/fileupload/v1/fileupload_grpc.py +0 -27
  319. viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.py +0 -18
  320. viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.pyi +0 -45
  321. viam/proto/rpc/examples/fileupload/__init__.py +0 -18
  322. viam/services/sensors/__init__.py +0 -5
  323. viam/services/sensors/client.py +0 -65
  324. viam_sdk-0.25.2.dist-info/LICENSE +0 -202
  325. viam_sdk-0.25.2.dist-info/RECORD +0 -442
  326. /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/__init__.py +0 -0
  327. /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/v1/__init__.py +0 -0
  328. /LICENSE → /viam_sdk-0.62.0.dist-info/licenses/LICENSE +0 -0
@@ -4,7 +4,7 @@ from datetime import timedelta
4
4
  from typing import Any, Dict, Final, List, Optional
5
5
 
6
6
  from viam.proto.component.board import PowerMode, ReadAnalogReaderResponse, StreamTicksResponse
7
- from viam.resource.types import RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, Subtype
7
+ from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT
8
8
  from viam.streams import Stream
9
9
 
10
10
  from ..component_base import ComponentBase
@@ -31,10 +31,10 @@ class Board(ComponentBase):
31
31
 
32
32
  from viam.components.board import Board
33
33
 
34
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
34
+ For more information, see `Board component <https://docs.viam.com/dev/reference/apis/components/board/>`_.
35
35
  """
36
36
 
37
- SUBTYPE: Final = Subtype( # pyright: ignore [reportIncompatibleVariableOverride]
37
+ API: Final = API( # pyright: ignore [reportIncompatibleVariableOverride]
38
38
  RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, "board"
39
39
  )
40
40
 
@@ -52,7 +52,7 @@ class Board(ComponentBase):
52
52
  the reader's minimum and maximum possible values, and its step size (the minimum possible
53
53
  change between values it can read).
54
54
 
55
- For more information, see `analogs <https://docs.viam.com/components/board/#analogs>`_.
55
+ For more information, see `analogs <https://docs.viam.com/dev/reference/apis/components/board/#analogs>`_.
56
56
  """
57
57
 
58
58
  def __init__(self, name: str):
@@ -65,10 +65,10 @@ class Board(ComponentBase):
65
65
 
66
66
  ::
67
67
 
68
- my_board = Board.from_robot(robot=robot, name="my_board")
68
+ my_board = Board.from_robot(robot=machine, name="my_board")
69
69
 
70
70
  # Get the Analog "my_example_analog_reader".
71
- reader = await my_board.analog_reader_by_name(
71
+ reader = await my_board.analog_by_name(
72
72
  name="my_example_analog_reader")
73
73
 
74
74
  # Get the value of the digital signal "my_example_analog_reader" has most
@@ -78,7 +78,7 @@ class Board(ComponentBase):
78
78
  Returns:
79
79
  Value: The current value, including the min, max, and step_size of the reader.
80
80
 
81
- For more information, see `Board component Analog API <https://docs.viam.com/components/board/#analog-api>`_.
81
+ For more information, see `Board component Analog API <https://docs.viam.com/dev/reference/apis/components/board/#analog-api>`_.
82
82
  """
83
83
  ...
84
84
 
@@ -89,7 +89,7 @@ class Board(ComponentBase):
89
89
 
90
90
  ::
91
91
 
92
- my_board = Board.from_robot(robot=robot, name="my_board")
92
+ my_board = Board.from_robot(robot=machine, name="my_board")
93
93
 
94
94
  # Get the Analog "my_example_analog_writer".
95
95
  writer = await my_board.analog_by_name(
@@ -100,7 +100,7 @@ class Board(ComponentBase):
100
100
  Args:
101
101
  value (int): Value to write to the analog writer.
102
102
 
103
- For more information, see `Board component Analog API <https://docs.viam.com/components/board/#analog-api>`_.
103
+ For more information, see `Board component Analog API <https://docs.viam.com/dev/reference/apis/components/board/#analog-api>`_.
104
104
  """
105
105
  ...
106
106
 
@@ -110,7 +110,7 @@ class Board(ComponentBase):
110
110
  when interrupted, calls the added callbacks. Post processors can
111
111
  be added to modify what Value it ultimately returns.
112
112
 
113
- For more information, see `digital_interrupts <https://docs.viam.com/components/board/#digital_interrupts>`_.
113
+ For more information, see `digital_interrupts <https://docs.viam.com/dev/reference/apis/components/board/#digital_interrupts>`_.
114
114
  """
115
115
 
116
116
  name: str
@@ -127,7 +127,7 @@ class Board(ComponentBase):
127
127
 
128
128
  ::
129
129
 
130
- my_board = Board.from_robot(robot=robot, name="my_board")
130
+ my_board = Board.from_robot(robot=machine, name="my_board")
131
131
 
132
132
  # Get the DigitalInterrupt "my_example_digital_interrupt".
133
133
  interrupt = await my_board.digital_interrupt_by_name(
@@ -141,7 +141,7 @@ class Board(ComponentBase):
141
141
  int: The current value.
142
142
 
143
143
  For more information, see
144
- `Board component DigitalInterrupt API <https://docs.viam.com/components/board/#digitalinterrupt-api>`_.
144
+ `Board component DigitalInterrupt API <https://docs.viam.com/dev/reference/apis/components/board/#digitalinterrupt-api>`_.
145
145
  """
146
146
  ...
147
147
 
@@ -163,18 +163,18 @@ class Board(ComponentBase):
163
163
 
164
164
  ::
165
165
 
166
- my_board = Board.from_robot(robot=robot, name="my_board")
166
+ my_board = Board.from_robot(robot=machine, name="my_board")
167
167
 
168
168
  # Get the GPIOPin with pin number 15.
169
169
  pin = await my_board.gpio_pin_by_name(name="15")
170
170
 
171
171
  # Set the pin to high.
172
- await pin.set(high="true")
172
+ await pin.set(high=True)
173
173
 
174
174
  Args:
175
175
  high (bool): When true, sets the pin to high. When false, sets the pin to low.
176
176
 
177
- For more information, see `GPIOPin API <https://docs.viam.com/components/board/#gpiopin-api>`_.
177
+ For more information, see `GPIOPin API <https://docs.viam.com/dev/reference/apis/components/board/#gpiopin-api>`_.
178
178
  """
179
179
  ...
180
180
 
@@ -185,7 +185,7 @@ class Board(ComponentBase):
185
185
 
186
186
  ::
187
187
 
188
- my_board = Board.from_robot(robot=robot, name="my_board")
188
+ my_board = Board.from_robot(robot=machine, name="my_board")
189
189
 
190
190
  # Get the GPIOPin with pin number 15.
191
191
  pin = await my_board.gpio_pin_by_name(name="15")
@@ -196,7 +196,7 @@ class Board(ComponentBase):
196
196
  Returns:
197
197
  bool: Indicates if the state of the pin is high.
198
198
 
199
- For more information, see `GPIOPin API <https://docs.viam.com/components/board/#gpiopin-api>`_.
199
+ For more information, see `GPIOPin API <https://docs.viam.com/dev/reference/apis/components/board/#gpiopin-api>`_.
200
200
  """
201
201
  ...
202
202
 
@@ -207,7 +207,7 @@ class Board(ComponentBase):
207
207
 
208
208
  ::
209
209
 
210
- my_board = Board.from_robot(robot=robot, name="my_board")
210
+ my_board = Board.from_robot(robot=machine, name="my_board")
211
211
 
212
212
  # Get the GPIOPin with pin number 15.
213
213
  pin = await my_board.gpio_pin_by_name(name="15")
@@ -218,7 +218,7 @@ class Board(ComponentBase):
218
218
  Returns:
219
219
  float: The duty cycle.
220
220
 
221
- For more information, see `GPIOPin API <https://docs.viam.com/components/board/#gpiopin-api>`_.
221
+ For more information, see `GPIOPin API <https://docs.viam.com/dev/reference/apis/components/board/#gpiopin-api>`_.
222
222
  """
223
223
  ...
224
224
 
@@ -229,19 +229,19 @@ class Board(ComponentBase):
229
229
 
230
230
  ::
231
231
 
232
- my_board = Board.from_robot(robot=robot, name="my_board")
232
+ my_board = Board.from_robot(robot=machine, name="my_board")
233
233
 
234
234
  # Get the GPIOPin with pin number 15.
235
235
  pin = await my_board.gpio_pin_by_name(name="15")
236
236
 
237
237
  # Set the duty cycle to .6, meaning that this pin will be in the high state for
238
238
  # 60% of the duration of the PWM interval period.
239
- await pin.set_pwm(cycle=.6)
239
+ await pin.set_pwm(duty_cycle=.6)
240
240
 
241
241
  Args:
242
242
  duty_cycle (float): The duty cycle.
243
243
 
244
- For more information, see `GPIOPin API <https://docs.viam.com/components/board/#gpiopin-api>`_.
244
+ For more information, see `GPIOPin API <https://docs.viam.com/dev/reference/apis/components/board/#gpiopin-api>`_.
245
245
  """
246
246
  ...
247
247
 
@@ -252,7 +252,7 @@ class Board(ComponentBase):
252
252
 
253
253
  ::
254
254
 
255
- my_board = Board.from_robot(robot=robot, name="my_board")
255
+ my_board = Board.from_robot(robot=machine, name="my_board")
256
256
 
257
257
  # Get the GPIOPin with pin number 15.
258
258
  pin = await my_board.gpio_pin_by_name(name="15")
@@ -263,7 +263,7 @@ class Board(ComponentBase):
263
263
  Returns:
264
264
  int: The PWM frequency.
265
265
 
266
- For more information, see `GPIOPin API <https://docs.viam.com/components/board/#gpiopin-api>`_.
266
+ For more information, see `GPIOPin API <https://docs.viam.com/dev/reference/apis/components/board/#gpiopin-api>`_.
267
267
  """
268
268
  ...
269
269
 
@@ -282,7 +282,7 @@ class Board(ComponentBase):
282
282
 
283
283
  ::
284
284
 
285
- my_board = Board.from_robot(robot=robot, name="my_board")
285
+ my_board = Board.from_robot(robot=machine, name="my_board")
286
286
 
287
287
  # Get the GPIOPin with pin number 15.
288
288
  pin = await my_board.gpio_pin_by_name(name="15")
@@ -293,7 +293,7 @@ class Board(ComponentBase):
293
293
  Args:
294
294
  frequency (int): The frequency, in Hz.
295
295
 
296
- For more information, see `GPIOPin API <https://docs.viam.com/components/board/#gpiopin-api>`_.
296
+ For more information, see `GPIOPin API <https://docs.viam.com/dev/reference/apis/components/board/#gpiopin-api>`_.
297
297
  """
298
298
  ...
299
299
 
@@ -304,7 +304,7 @@ class Board(ComponentBase):
304
304
 
305
305
  ::
306
306
 
307
- my_board = Board.from_robot(robot=robot, name="my_board")
307
+ my_board = Board.from_robot(robot=machine, name="my_board")
308
308
 
309
309
  # Get the Analog "my_example_analog_reader".
310
310
  reader = await my_board.analog_by_name(name="my_example_analog_reader")
@@ -315,7 +315,7 @@ class Board(ComponentBase):
315
315
  Returns:
316
316
  Analog: The analog reader or writer.
317
317
 
318
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
318
+ For more information, see `Board component <https://docs.viam.com/dev/reference/apis/components/board/#analogbyname>`_.
319
319
  """
320
320
  ...
321
321
 
@@ -326,7 +326,7 @@ class Board(ComponentBase):
326
326
 
327
327
  ::
328
328
 
329
- my_board = Board.from_robot(robot=robot, name="my_board")
329
+ my_board = Board.from_robot(robot=machine, name="my_board")
330
330
 
331
331
  # Get the DigitalInterrupt "my_example_digital_interrupt".
332
332
  interrupt = await my_board.digital_interrupt_by_name(
@@ -338,7 +338,7 @@ class Board(ComponentBase):
338
338
  Returns:
339
339
  DigitalInterrupt: The digital interrupt.
340
340
 
341
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
341
+ For more information, see `Board component <https://docs.viam.com/dev/reference/apis/components/board/#digitalinterruptbyname>`_.
342
342
  """
343
343
  ...
344
344
 
@@ -349,7 +349,7 @@ class Board(ComponentBase):
349
349
 
350
350
  ::
351
351
 
352
- my_board = Board.from_robot(robot=robot, name="my_board")
352
+ my_board = Board.from_robot(robot=machine, name="my_board")
353
353
 
354
354
  # Get the GPIOPin with pin number 15.
355
355
  pin = await my_board.gpio_pin_by_name(name="15")
@@ -360,45 +360,7 @@ class Board(ComponentBase):
360
360
  Returns:
361
361
  GPIOPin: The pin.
362
362
 
363
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
364
- """
365
- ...
366
-
367
- @abc.abstractmethod
368
- async def analog_names(self) -> List[str]:
369
- """
370
- Get the names of all known analog readers and/or writers.
371
-
372
- ::
373
-
374
- my_board = Board.from_robot(robot=robot, name="my_board")
375
-
376
- # Get the name of every Analog configured on the board.
377
- names = await my_board.analog_names()
378
-
379
- Returns:
380
- List[str]: The list of names of all known analog readers/writers.
381
-
382
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
383
- """
384
- ...
385
-
386
- @abc.abstractmethod
387
- async def digital_interrupt_names(self) -> List[str]:
388
- """
389
- Get the names of all known digital interrupts.
390
-
391
- ::
392
-
393
- my_board = Board.from_robot(robot=robot, name="my_board")
394
-
395
- # Get the name of every DigitalInterrupt configured on the board.
396
- names = await my_board.digital_interrupt_names()
397
-
398
- Returns:
399
- List[str]: The names of the digital interrupts.
400
-
401
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
363
+ For more information, see `Board component <https://docs.viam.com/dev/reference/apis/components/board/#gpiopinbyname>`_.
402
364
  """
403
365
  ...
404
366
 
@@ -411,7 +373,7 @@ class Board(ComponentBase):
411
373
 
412
374
  ::
413
375
 
414
- my_board = Board.from_robot(robot=robot, name="my_board")
376
+ my_board = Board.from_robot(robot=machine, name="my_board")
415
377
 
416
378
  # Set the power mode of the board to OFFLINE_DEEP.
417
379
  status = await my_board.set_power_mode(mode=PowerMode.POWER_MODE_OFFLINE_DEEP)
@@ -420,7 +382,7 @@ class Board(ComponentBase):
420
382
  mode (PowerMode): The desired power mode.
421
383
  duration (Optional[timedelta]): Requested duration to stay in power mode.
422
384
 
423
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
385
+ For more information, see `Board component <https://docs.viam.com/dev/reference/apis/components/board/#setpowermode>`_.
424
386
  """
425
387
  ...
426
388
 
@@ -432,12 +394,12 @@ class Board(ComponentBase):
432
394
  ::
433
395
 
434
396
 
435
- my_board = Board.from_robot(robot=robot, name="my_board")
436
- di8 = await my_board.digital_interrupt_by_name(name="8"))
437
- di11 = await my_board.digital_interrupt_by_name(name="11"))
397
+ my_board = Board.from_robot(robot=machine, name="my_board")
398
+ di8 = await my_board.digital_interrupt_by_name(name="8")
399
+ di11 = await my_board.digital_interrupt_by_name(name="11")
438
400
 
439
401
  # Iterate over stream of ticks from pins 8 and 11.
440
- async for tick in my_board.stream_ticks([di8, di11]):
402
+ async for tick in await my_board.stream_ticks([di8, di11]):
441
403
  print(f"Pin {tick.pin_name} changed to {'high' if tick.high else 'low'} at {tick.time}")
442
404
 
443
405
 
@@ -447,6 +409,6 @@ class Board(ComponentBase):
447
409
  Returns:
448
410
  TickStream: stream of ticks.
449
411
 
450
- For more information, see `Board component <https://docs.viam.com/components/board/>`_.
412
+ For more information, see `Board component <https://docs.viam.com/dev/reference/apis/components/board/#streamticks>`_.
451
413
  """
452
414
  ...
@@ -5,7 +5,6 @@ from google.protobuf.duration_pb2 import Duration
5
5
  from grpclib.client import Channel
6
6
  from grpclib.client import Stream as ClientStream
7
7
 
8
- from viam.logging import getLogger
9
8
  from viam.proto.common import DoCommandRequest, DoCommandResponse, Geometry
10
9
  from viam.proto.component.board import (
11
10
  BoardServiceStub,
@@ -27,14 +26,12 @@ from viam.proto.component.board import (
27
26
  StreamTicksResponse,
28
27
  WriteAnalogRequest,
29
28
  )
30
- from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase
29
+ from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase, ResourceRPCClientBase
31
30
  from viam.streams import StreamWithIterator
32
31
  from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict
33
32
 
34
33
  from .board import Board, TickStream
35
34
 
36
- LOGGER = getLogger(__name__)
37
-
38
35
 
39
36
  class AnalogClient(Board.Analog):
40
37
  def __init__(self, name: str, board: "BoardClient"):
@@ -46,12 +43,11 @@ class AnalogClient(Board.Analog):
46
43
  *,
47
44
  extra: Optional[Dict[str, Any]] = None,
48
45
  timeout: Optional[float] = None,
49
- **__,
46
+ **kwargs,
50
47
  ) -> Board.Analog.Value:
51
- if extra is None:
52
- extra = {}
48
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
53
49
  request = ReadAnalogReaderRequest(board_name=self.board.name, analog_reader_name=self.name, extra=dict_to_struct(extra))
54
- return await self.board.client.ReadAnalogReader(request, timeout=timeout)
50
+ return await self.board.client.ReadAnalogReader(request, timeout=timeout, metadata=md)
55
51
 
56
52
  async def write(
57
53
  self,
@@ -61,10 +57,9 @@ class AnalogClient(Board.Analog):
61
57
  timeout: Optional[float] = None,
62
58
  **kwargs,
63
59
  ):
64
- if extra is None:
65
- extra = {}
60
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
66
61
  request = WriteAnalogRequest(name=self.board.name, pin=self.name, value=value, extra=dict_to_struct(extra))
67
- await self.board.client.WriteAnalog(request, timeout=timeout)
62
+ await self.board.client.WriteAnalog(request, timeout=timeout, metadata=md)
68
63
 
69
64
 
70
65
  class DigitalInterruptClient(Board.DigitalInterrupt):
@@ -77,12 +72,11 @@ class DigitalInterruptClient(Board.DigitalInterrupt):
77
72
  *,
78
73
  extra: Optional[Dict[str, Any]] = None,
79
74
  timeout: Optional[float] = None,
80
- **__,
75
+ **kwargs,
81
76
  ) -> int:
82
- if extra is None:
83
- extra = {}
77
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
84
78
  request = GetDigitalInterruptValueRequest(board_name=self.board.name, digital_interrupt_name=self.name, extra=dict_to_struct(extra))
85
- response: GetDigitalInterruptValueResponse = await self.board.client.GetDigitalInterruptValue(request, timeout=timeout)
79
+ response: GetDigitalInterruptValueResponse = await self.board.client.GetDigitalInterruptValue(request, timeout=timeout, metadata=md)
86
80
  return response.value
87
81
 
88
82
 
@@ -96,12 +90,11 @@ class GPIOPinClient(Board.GPIOPin):
96
90
  *,
97
91
  extra: Optional[Dict[str, Any]] = None,
98
92
  timeout: Optional[float] = None,
99
- **__,
93
+ **kwargs,
100
94
  ) -> bool:
101
- if extra is None:
102
- extra = {}
95
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
103
96
  request = GetGPIORequest(name=self.board.name, pin=self.name, extra=dict_to_struct(extra))
104
- response: GetGPIOResponse = await self.board.client.GetGPIO(request, timeout=timeout)
97
+ response: GetGPIOResponse = await self.board.client.GetGPIO(request, timeout=timeout, metadata=md)
105
98
  return response.high
106
99
 
107
100
  async def set(
@@ -110,24 +103,22 @@ class GPIOPinClient(Board.GPIOPin):
110
103
  *,
111
104
  extra: Optional[Dict[str, Any]] = None,
112
105
  timeout: Optional[float] = None,
113
- **__,
106
+ **kwargs,
114
107
  ):
115
- if extra is None:
116
- extra = {}
108
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
117
109
  request = SetGPIORequest(name=self.board.name, pin=self.name, high=high, extra=dict_to_struct(extra))
118
- await self.board.client.SetGPIO(request, timeout=timeout)
110
+ await self.board.client.SetGPIO(request, timeout=timeout, metadata=md)
119
111
 
120
112
  async def get_pwm(
121
113
  self,
122
114
  *,
123
115
  extra: Optional[Dict[str, Any]] = None,
124
116
  timeout: Optional[float] = None,
125
- **__,
117
+ **kwargs,
126
118
  ) -> float:
127
- if extra is None:
128
- extra = {}
119
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
129
120
  request = PWMRequest(name=self.board.name, pin=self.name, extra=dict_to_struct(extra))
130
- response: PWMResponse = await self.board.client.PWM(request, timeout=timeout)
121
+ response: PWMResponse = await self.board.client.PWM(request, timeout=timeout, metadata=md)
131
122
  return response.duty_cycle_pct
132
123
 
133
124
  async def set_pwm(
@@ -136,24 +127,22 @@ class GPIOPinClient(Board.GPIOPin):
136
127
  *,
137
128
  extra: Optional[Dict[str, Any]] = None,
138
129
  timeout: Optional[float] = None,
139
- **__,
130
+ **kwargs,
140
131
  ):
141
- if extra is None:
142
- extra = {}
132
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
143
133
  request = SetPWMRequest(name=self.board.name, pin=self.name, duty_cycle_pct=duty_cycle, extra=dict_to_struct(extra))
144
- await self.board.client.SetPWM(request, timeout=timeout)
134
+ await self.board.client.SetPWM(request, timeout=timeout, metadata=md)
145
135
 
146
136
  async def get_pwm_frequency(
147
137
  self,
148
138
  *,
149
139
  extra: Optional[Dict[str, Any]] = None,
150
140
  timeout: Optional[float] = None,
151
- **__,
141
+ **kwargs,
152
142
  ) -> int:
153
- if extra is None:
154
- extra = {}
143
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
155
144
  request = PWMFrequencyRequest(name=self.board.name, pin=self.name, extra=dict_to_struct(extra))
156
- response: PWMFrequencyResponse = await self.board.client.PWMFrequency(request, timeout=timeout)
145
+ response: PWMFrequencyResponse = await self.board.client.PWMFrequency(request, timeout=timeout, metadata=md)
157
146
  return response.frequency_hz
158
147
 
159
148
  async def set_pwm_frequency(
@@ -162,12 +151,11 @@ class GPIOPinClient(Board.GPIOPin):
162
151
  *,
163
152
  extra: Optional[Dict[str, Any]] = None,
164
153
  timeout: Optional[float] = None,
165
- **__,
154
+ **kwargs,
166
155
  ):
167
- if extra is None:
168
- extra = {}
156
+ md = kwargs.get("metadata", ResourceRPCClientBase.Metadata()).proto
169
157
  request = SetPWMFrequencyRequest(name=self.board.name, pin=self.name, frequency_hz=frequency, extra=dict_to_struct(extra))
170
- await self.board.client.SetPWMFrequency(request, timeout=timeout)
158
+ await self.board.client.SetPWMFrequency(request, timeout=timeout, metadata=md)
171
159
 
172
160
 
173
161
  class BoardClient(Board, ReconfigurableResourceRPCClientBase):
@@ -196,25 +184,16 @@ class BoardClient(Board, ReconfigurableResourceRPCClientBase):
196
184
  async def gpio_pin_by_name(self, name: str) -> Board.GPIOPin:
197
185
  return GPIOPinClient(name, self)
198
186
 
199
- async def analog_names(self) -> List[str]:
200
- if self._analog_names is None:
201
- return []
202
- return self._analog_names
203
-
204
- async def digital_interrupt_names(self) -> List[str]:
205
- if self._digital_interrupt_names is None:
206
- return []
207
- return self._digital_interrupt_names
208
-
209
187
  async def do_command(
210
188
  self,
211
189
  command: Mapping[str, ValueTypes],
212
190
  *,
213
191
  timeout: Optional[float] = None,
214
- **__,
192
+ **kwargs,
215
193
  ) -> Mapping[str, ValueTypes]:
194
+ md = kwargs.get("metadata", self.Metadata()).proto
216
195
  request = DoCommandRequest(name=self.name, command=dict_to_struct(command))
217
- response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout)
196
+ response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout, metadata=md)
218
197
  return struct_to_dict(response.result)
219
198
 
220
199
  async def set_power_mode(
@@ -223,48 +202,35 @@ class BoardClient(Board, ReconfigurableResourceRPCClientBase):
223
202
  duration: Optional[timedelta] = None,
224
203
  *,
225
204
  timeout: Optional[float] = None,
226
- **__,
205
+ **kwargs,
227
206
  ):
207
+ md = kwargs.get("metadata", self.Metadata()).proto
228
208
  duration_pb: Optional[Duration] = None
229
209
  if duration is not None:
230
210
  duration_pb = [(d, d.FromTimedelta(duration)) for d in [Duration()]][0][0]
231
211
  request = SetPowerModeRequest(name=self.name, power_mode=mode, duration=duration_pb)
232
- await self.client.SetPowerMode(request, timeout=timeout)
233
-
234
- async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]:
235
- return await get_geometries(self.client, self.name, extra, timeout)
212
+ await self.client.SetPowerMode(request, timeout=timeout, metadata=md)
236
213
 
237
- async def write_analog(
238
- self,
239
- pin: str,
240
- value: int,
241
- *,
242
- extra: Optional[Dict[str, Any]] = None,
243
- timeout: Optional[float] = None,
244
- **__,
245
- ):
246
- if extra is None:
247
- extra = {}
248
- request = WriteAnalogRequest(name=self.name, pin=pin, value=value, extra=dict_to_struct(extra))
249
- await self.client.WriteAnalog(request, timeout=timeout)
214
+ async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> List[Geometry]:
215
+ md = kwargs.get("metadata", self.Metadata())
216
+ return await get_geometries(self.client, self.name, extra, timeout, md)
250
217
 
251
218
  async def stream_ticks(
252
219
  self,
253
220
  interrupts: List[Board.DigitalInterrupt],
254
221
  *,
255
222
  extra: Optional[Dict[str, Any]] = None,
256
- **__,
223
+ **kwargs,
257
224
  ) -> TickStream:
258
- if extra is None:
259
- extra = {}
260
225
  names = []
261
226
  for di in interrupts:
262
227
  names.append(di.name)
263
228
  request = StreamTicksRequest(name=self.name, pin_names=names, extra=dict_to_struct(extra))
264
229
 
265
230
  async def read():
231
+ md = kwargs.get("metadata", self.Metadata()).proto
266
232
  tick_stream: ClientStream[StreamTicksRequest, StreamTicksResponse]
267
- async with self.client.StreamTicks.open() as tick_stream:
233
+ async with self.client.StreamTicks.open(metadata=md) as tick_stream:
268
234
  try:
269
235
  await tick_stream.send_message(request, end=True)
270
236
  async for tick in tick_stream:
@@ -0,0 +1,10 @@
1
+ import viam.gen.component.button.v1.button_pb2
2
+ from viam.resource.registry import Registry, ResourceRegistration
3
+
4
+ from .button import Button
5
+ from .client import ButtonClient
6
+ from .service import ButtonRPCService
7
+
8
+ __all__ = ["Button"]
9
+
10
+ Registry.register_api(ResourceRegistration(Button, ButtonRPCService, lambda name, channel: ButtonClient(name, channel)))
@@ -0,0 +1,41 @@
1
+ import abc
2
+ from typing import Any, Final, Mapping, Optional
3
+
4
+ from viam.components.component_base import ComponentBase
5
+ from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT
6
+
7
+
8
+ class Button(ComponentBase):
9
+ """
10
+ Button represents a device that can be pushed.
11
+
12
+ This acts as an abstract base class for any drivers representing specific
13
+ button implementations. This cannot be used on its own. If the ``__init__()`` function is
14
+ overridden, it must call the ``super().__init__()`` function.
15
+
16
+ ::
17
+
18
+ from viam.components.button import Button
19
+
20
+ For more information, see `Button component <https://docs.viam.com/dev/reference/apis/components/button/>` _.
21
+ """
22
+
23
+ API: Final = API( # pyright: ignore [reportIncompatibleVariableOverride]
24
+ RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, "button"
25
+ )
26
+
27
+ @abc.abstractmethod
28
+ async def push(self, *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> None:
29
+ """
30
+ Push the button.
31
+
32
+ ::
33
+
34
+ my_button = Button.from_robot(robot=machine, name="my_button")
35
+
36
+ # Push the button
37
+ await my_button.push()
38
+
39
+ For more information, see `Button component <https://docs.viam.com/dev/reference/apis/components/button/>` _.
40
+ """
41
+ ...