viam-sdk 0.3.0__py3-none-linux_armv6l.whl → 0.66.0__py3-none-linux_armv6l.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.
- viam/__init__.py +29 -2
- viam/app/_logs.py +34 -0
- viam/app/app_client.py +2696 -0
- viam/app/billing_client.py +185 -0
- viam/app/data_client.py +2231 -0
- viam/app/ml_training_client.py +249 -0
- viam/app/provisioning_client.py +93 -0
- viam/app/viam_client.py +275 -0
- viam/components/arm/__init__.py +3 -26
- viam/components/arm/arm.py +123 -8
- viam/components/arm/client.py +37 -24
- viam/components/arm/service.py +35 -32
- viam/components/audio_in/__init__.py +24 -0
- viam/components/audio_in/audio_in.py +74 -0
- viam/components/audio_in/client.py +76 -0
- viam/components/audio_in/service.py +83 -0
- viam/components/audio_out/__init__.py +21 -0
- viam/components/audio_out/audio_out.py +72 -0
- viam/components/audio_out/client.py +67 -0
- viam/components/audio_out/service.py +63 -0
- viam/components/base/__init__.py +6 -11
- viam/components/base/base.py +134 -8
- viam/components/base/client.py +51 -23
- viam/components/base/service.py +33 -30
- viam/components/board/__init__.py +3 -12
- viam/components/board/board.py +247 -91
- viam/components/board/client.py +149 -83
- viam/components/board/service.py +63 -33
- viam/components/button/__init__.py +10 -0
- viam/components/button/button.py +41 -0
- viam/components/button/client.py +52 -0
- viam/components/button/service.py +46 -0
- viam/components/camera/__init__.py +3 -3
- viam/components/camera/camera.py +62 -27
- viam/components/camera/client.py +59 -27
- viam/components/camera/service.py +42 -65
- viam/components/component_base.py +28 -5
- viam/components/encoder/__init__.py +1 -1
- viam/components/encoder/client.py +25 -14
- viam/components/encoder/encoder.py +48 -10
- viam/components/encoder/service.py +14 -18
- viam/components/gantry/__init__.py +1 -13
- viam/components/gantry/client.py +80 -25
- viam/components/gantry/gantry.py +123 -9
- viam/components/gantry/service.py +51 -29
- viam/components/generic/__init__.py +1 -1
- viam/components/generic/client.py +21 -8
- viam/components/generic/generic.py +10 -2
- viam/components/generic/service.py +12 -7
- viam/components/gripper/__init__.py +3 -13
- viam/components/gripper/client.py +69 -21
- viam/components/gripper/gripper.py +123 -3
- viam/components/gripper/service.py +44 -22
- viam/components/input/__init__.py +1 -14
- viam/components/input/client.py +55 -23
- viam/components/input/input.py +106 -3
- viam/components/input/service.py +16 -21
- viam/components/motor/__init__.py +1 -21
- viam/components/motor/client.py +56 -33
- viam/components/motor/motor.py +127 -4
- viam/components/motor/service.py +33 -44
- viam/components/movement_sensor/__init__.py +1 -1
- viam/components/movement_sensor/client.py +102 -45
- viam/components/movement_sensor/movement_sensor.py +130 -61
- viam/components/movement_sensor/service.py +38 -41
- viam/components/pose_tracker/__init__.py +1 -1
- viam/components/pose_tracker/client.py +18 -7
- viam/components/pose_tracker/pose_tracker.py +4 -2
- viam/components/pose_tracker/service.py +12 -10
- viam/components/power_sensor/__init__.py +17 -0
- viam/components/power_sensor/client.py +86 -0
- viam/components/power_sensor/power_sensor.py +104 -0
- viam/components/power_sensor/service.py +72 -0
- viam/components/sensor/__init__.py +2 -1
- viam/components/sensor/client.py +26 -10
- viam/components/sensor/sensor.py +22 -4
- viam/components/sensor/service.py +20 -11
- viam/components/servo/__init__.py +1 -13
- viam/components/servo/client.py +47 -21
- viam/components/servo/service.py +15 -22
- viam/components/servo/servo.py +61 -2
- viam/components/switch/__init__.py +10 -0
- viam/components/switch/client.py +83 -0
- viam/components/switch/service.py +72 -0
- viam/components/switch/switch.py +98 -0
- viam/errors.py +10 -0
- viam/gen/app/agent/v1/agent_grpc.py +29 -0
- viam/gen/app/agent/v1/agent_pb2.py +47 -0
- viam/gen/app/agent/v1/agent_pb2.pyi +280 -0
- viam/gen/app/cloudslam/v1/__init__.py +0 -0
- viam/gen/app/cloudslam/v1/cloud_slam_grpc.py +70 -0
- viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +54 -0
- viam/gen/app/cloudslam/v1/cloud_slam_pb2.pyi +384 -0
- viam/gen/app/data/v1/data_grpc.py +197 -8
- viam/gen/app/data/v1/data_pb2.py +238 -99
- viam/gen/app/data/v1/data_pb2.pyi +1222 -259
- viam/gen/app/datapipelines/__init__.py +0 -0
- viam/gen/app/datapipelines/v1/__init__.py +0 -0
- viam/gen/app/datapipelines/v1/data_pipelines_grpc.py +84 -0
- viam/gen/app/datapipelines/v1/data_pipelines_pb2.py +57 -0
- viam/gen/app/datapipelines/v1/data_pipelines_pb2.pyi +387 -0
- viam/gen/app/dataset/__init__.py +0 -0
- viam/gen/app/dataset/v1/__init__.py +0 -0
- viam/gen/app/dataset/v1/dataset_grpc.py +68 -0
- viam/gen/app/dataset/v1/dataset_pb2.py +44 -0
- viam/gen/app/dataset/v1/dataset_pb2.pyi +214 -0
- viam/gen/app/datasync/v1/data_sync_grpc.py +21 -4
- viam/gen/app/datasync/v1/data_sync_pb2.py +62 -128
- viam/gen/app/datasync/v1/data_sync_pb2.pyi +156 -199
- viam/gen/app/mlinference/__init__.py +0 -0
- viam/gen/app/mlinference/v1/__init__.py +0 -0
- viam/gen/app/mlinference/v1/ml_inference_grpc.py +28 -0
- viam/gen/app/mlinference/v1/ml_inference_pb2.py +23 -0
- viam/gen/app/mlinference/v1/ml_inference_pb2.pyi +63 -0
- viam/gen/app/mltraining/v1/ml_training_grpc.py +51 -3
- viam/gen/app/mltraining/v1/ml_training_pb2.py +135 -58
- viam/gen/app/mltraining/v1/ml_training_pb2.pyi +328 -39
- viam/gen/app/packages/v1/packages_grpc.py +15 -1
- viam/gen/app/packages/v1/packages_pb2.py +44 -64
- viam/gen/app/packages/v1/packages_pb2.pyi +75 -85
- viam/gen/app/v1/app_grpc.py +644 -3
- viam/gen/app/v1/app_pb2.py +695 -295
- viam/gen/app/v1/app_pb2.pyi +4488 -635
- viam/gen/app/v1/billing_grpc.py +53 -11
- viam/gen/app/v1/billing_pb2.py +94 -39
- viam/gen/app/v1/billing_pb2.pyi +391 -191
- viam/gen/app/v1/end_user_grpc.py +59 -0
- viam/gen/app/v1/end_user_pb2.py +55 -0
- viam/gen/app/v1/end_user_pb2.pyi +181 -0
- viam/gen/app/v1/robot_grpc.py +16 -1
- viam/gen/app/v1/robot_pb2.py +122 -94
- viam/gen/app/v1/robot_pb2.pyi +463 -123
- viam/gen/common/v1/common_pb2.py +87 -58
- viam/gen/common/v1/common_pb2.pyi +456 -149
- viam/gen/component/arm/v1/arm_grpc.py +58 -2
- viam/gen/component/arm/v1/arm_pb2.py +68 -51
- viam/gen/component/arm/v1/arm_pb2.pyi +108 -42
- viam/gen/component/audioin/__init__.py +0 -0
- viam/gen/component/audioin/v1/__init__.py +0 -0
- viam/gen/component/audioin/v1/audioin_grpc.py +54 -0
- viam/gen/component/audioin/v1/audioin_pb2.py +34 -0
- viam/gen/component/audioin/v1/audioin_pb2.pyi +94 -0
- viam/gen/component/audioinput/v1/audioinput_grpc.py +25 -2
- viam/gen/component/audioinput/v1/audioinput_pb2.py +36 -31
- viam/gen/component/audioinput/v1/audioinput_pb2.pyi +22 -22
- viam/gen/component/audioout/__init__.py +0 -0
- viam/gen/component/audioout/v1/__init__.py +0 -0
- viam/gen/component/audioout/v1/audioout_grpc.py +54 -0
- viam/gen/component/audioout/v1/audioout_pb2.py +32 -0
- viam/gen/component/audioout/v1/audioout_pb2.pyi +47 -0
- viam/gen/component/base/v1/base_grpc.py +42 -2
- viam/gen/component/base/v1/base_pb2.py +58 -47
- viam/gen/component/base/v1/base_pb2.pyi +65 -30
- viam/gen/component/board/v1/board_grpc.py +59 -7
- viam/gen/component/board/v1/board_pb2.py +94 -73
- viam/gen/component/board/v1/board_pb2.pyi +165 -68
- viam/gen/component/button/__init__.py +0 -0
- viam/gen/component/button/v1/__init__.py +0 -0
- viam/gen/component/button/v1/button_grpc.py +38 -0
- viam/gen/component/button/v1/button_pb2.py +28 -0
- viam/gen/component/button/v1/button_pb2.pyi +39 -0
- viam/gen/component/camera/v1/camera_grpc.py +38 -2
- viam/gen/component/camera/v1/camera_pb2.py +60 -43
- viam/gen/component/camera/v1/camera_pb2.pyi +191 -37
- viam/gen/component/encoder/v1/encoder_grpc.py +25 -2
- viam/gen/component/encoder/v1/encoder_pb2.py +36 -31
- viam/gen/component/encoder/v1/encoder_pb2.pyi +15 -15
- viam/gen/component/gantry/v1/gantry_grpc.py +47 -2
- viam/gen/component/gantry/v1/gantry_pb2.py +56 -43
- viam/gen/component/gantry/v1/gantry_pb2.pyi +67 -31
- viam/gen/component/generic/v1/generic_grpc.py +16 -2
- viam/gen/component/generic/v1/generic_pb2.py +16 -11
- viam/gen/component/gripper/v1/gripper_grpc.py +44 -2
- viam/gen/component/gripper/v1/gripper_pb2.py +48 -35
- viam/gen/component/gripper/v1/gripper_pb2.pyi +62 -24
- viam/gen/component/inputcontroller/v1/input_controller_grpc.py +28 -2
- viam/gen/component/inputcontroller/v1/input_controller_pb2.py +46 -41
- viam/gen/component/inputcontroller/v1/input_controller_pb2.pyi +32 -36
- viam/gen/component/motor/v1/motor_grpc.py +51 -2
- viam/gen/component/motor/v1/motor_pb2.py +78 -67
- viam/gen/component/motor/v1/motor_pb2.pyi +75 -46
- viam/gen/component/movementsensor/v1/movementsensor_grpc.py +48 -2
- viam/gen/component/movementsensor/v1/movementsensor_pb2.py +70 -63
- viam/gen/component/movementsensor/v1/movementsensor_pb2.pyi +84 -57
- viam/gen/component/posetracker/v1/pose_tracker_grpc.py +19 -2
- viam/gen/component/posetracker/v1/pose_tracker_pb2.py +26 -21
- viam/gen/component/posetracker/v1/pose_tracker_pb2.pyi +9 -13
- viam/gen/component/powersensor/__init__.py +0 -0
- viam/gen/component/powersensor/v1/__init__.py +0 -0
- viam/gen/component/powersensor/v1/powersensor_grpc.py +62 -0
- viam/gen/component/powersensor/v1/powersensor_pb2.py +42 -0
- viam/gen/component/powersensor/v1/powersensor_pb2.pyi +124 -0
- viam/gen/component/sensor/v1/sensor_grpc.py +21 -5
- viam/gen/component/sensor/v1/sensor_pb2.py +18 -22
- viam/gen/component/sensor/v1/sensor_pb2.pyi +1 -69
- viam/gen/component/servo/v1/servo_grpc.py +28 -2
- viam/gen/component/servo/v1/servo_pb2.py +42 -37
- viam/gen/component/servo/v1/servo_pb2.pyi +22 -26
- viam/gen/component/switch/__init__.py +0 -0
- viam/gen/component/switch/v1/__init__.py +0 -0
- viam/gen/component/switch/v1/switch_grpc.py +54 -0
- viam/gen/component/switch/v1/switch_pb2.py +40 -0
- viam/gen/component/switch/v1/switch_pb2.pyi +116 -0
- viam/gen/component/testecho/v1/testecho_grpc.py +15 -0
- viam/gen/component/testecho/v1/testecho_pb2.py +29 -26
- viam/gen/component/testecho/v1/testecho_pb2.pyi +16 -20
- viam/gen/module/v1/module_grpc.py +18 -0
- viam/gen/module/v1/module_pb2.py +36 -33
- viam/gen/module/v1/module_pb2.pyi +39 -34
- viam/gen/opentelemetry/__init__.py +0 -0
- viam/gen/opentelemetry/proto/__init__.py +0 -0
- viam/gen/opentelemetry/proto/common/__init__.py +0 -0
- viam/gen/opentelemetry/proto/common/v1/__init__.py +0 -0
- viam/gen/opentelemetry/proto/common/v1/common_grpc.py +0 -0
- viam/gen/opentelemetry/proto/common/v1/common_pb2.py +27 -0
- viam/gen/opentelemetry/proto/common/v1/common_pb2.pyi +208 -0
- viam/gen/opentelemetry/proto/resource/__init__.py +0 -0
- viam/gen/opentelemetry/proto/resource/v1/__init__.py +0 -0
- viam/gen/opentelemetry/proto/resource/v1/resource_grpc.py +0 -0
- viam/gen/opentelemetry/proto/resource/v1/resource_pb2.py +18 -0
- viam/gen/opentelemetry/proto/resource/v1/resource_pb2.pyi +59 -0
- viam/gen/opentelemetry/proto/trace/__init__.py +0 -0
- viam/gen/opentelemetry/proto/trace/v1/__init__.py +0 -0
- viam/gen/opentelemetry/proto/trace/v1/trace_grpc.py +0 -0
- viam/gen/opentelemetry/proto/trace/v1/trace_pb2.py +37 -0
- viam/gen/opentelemetry/proto/trace/v1/trace_pb2.pyi +402 -0
- viam/gen/proto/rpc/examples/echo/v1/echo_grpc.py +12 -0
- viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +25 -22
- viam/gen/proto/rpc/examples/echo/v1/echo_pb2.pyi +13 -17
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_grpc.py +12 -0
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +23 -20
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.pyi +13 -17
- viam/gen/proto/rpc/v1/auth_grpc.py +11 -0
- viam/gen/proto/rpc/v1/auth_pb2.py +27 -24
- viam/gen/proto/rpc/v1/auth_pb2.pyi +12 -16
- viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +35 -32
- viam/gen/proto/rpc/webrtc/v1/grpc_pb2.pyi +37 -41
- viam/gen/proto/rpc/webrtc/v1/signaling_grpc.py +15 -0
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +62 -57
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +78 -69
- viam/gen/provisioning/__init__.py +0 -0
- viam/gen/provisioning/v1/__init__.py +0 -0
- viam/gen/provisioning/v1/provisioning_grpc.py +59 -0
- viam/gen/provisioning/v1/provisioning_pb2.py +45 -0
- viam/gen/provisioning/v1/provisioning_pb2.pyi +229 -0
- viam/gen/robot/v1/robot_grpc.py +144 -15
- viam/gen/robot/v1/robot_pb2.py +193 -119
- viam/gen/robot/v1/robot_pb2.pyi +565 -137
- viam/gen/service/datamanager/v1/data_manager_grpc.py +20 -2
- viam/gen/service/datamanager/v1/data_manager_pb2.py +27 -17
- viam/gen/service/datamanager/v1/data_manager_pb2.pyi +52 -10
- viam/gen/service/discovery/__init__.py +0 -0
- viam/gen/service/discovery/v1/__init__.py +0 -0
- viam/gen/service/discovery/v1/discovery_grpc.py +39 -0
- viam/gen/service/discovery/v1/discovery_pb2.py +29 -0
- viam/gen/service/discovery/v1/discovery_pb2.pyi +51 -0
- viam/gen/service/generic/__init__.py +0 -0
- viam/gen/service/generic/v1/__init__.py +0 -0
- viam/gen/service/generic/v1/generic_grpc.py +29 -0
- viam/gen/service/generic/v1/generic_pb2.py +21 -0
- viam/gen/service/generic/v1/generic_pb2.pyi +6 -0
- viam/gen/service/mlmodel/v1/mlmodel_grpc.py +9 -0
- viam/gen/service/mlmodel/v1/mlmodel_pb2.py +76 -29
- viam/gen/service/mlmodel/v1/mlmodel_pb2.pyi +307 -28
- viam/gen/service/motion/v1/motion_grpc.py +42 -4
- viam/gen/service/motion/v1/motion_pb2.py +119 -51
- viam/gen/service/motion/v1/motion_pb2.pyi +595 -120
- viam/gen/service/navigation/v1/navigation_grpc.py +49 -1
- viam/gen/service/navigation/v1/navigation_pb2.py +76 -51
- viam/gen/service/navigation/v1/navigation_pb2.pyi +188 -33
- viam/gen/service/sensors/v1/sensors_grpc.py +12 -0
- viam/gen/service/sensors/v1/sensors_pb2.py +60 -29
- viam/gen/service/sensors/v1/sensors_pb2.pyi +18 -21
- viam/gen/service/shell/v1/shell_grpc.py +27 -1
- viam/gen/service/shell/v1/shell_pb2.py +37 -15
- viam/gen/service/shell/v1/shell_pb2.pyi +260 -7
- viam/gen/service/slam/v1/slam_grpc.py +24 -2
- viam/gen/service/slam/v1/slam_pb2.py +44 -30
- viam/gen/service/slam/v1/slam_pb2.pyi +128 -27
- viam/gen/service/video/__init__.py +0 -0
- viam/gen/service/video/v1/__init__.py +0 -0
- viam/gen/service/video/v1/video_grpc.py +39 -0
- viam/gen/service/video/v1/video_pb2.py +29 -0
- viam/gen/service/video/v1/video_pb2.pyi +72 -0
- viam/gen/service/vision/v1/vision_grpc.py +39 -1
- viam/gen/service/vision/v1/vision_pb2.py +61 -45
- viam/gen/service/vision/v1/vision_pb2.pyi +180 -41
- viam/gen/service/worldstatestore/__init__.py +0 -0
- viam/gen/service/worldstatestore/v1/__init__.py +0 -0
- viam/gen/service/worldstatestore/v1/world_state_store_grpc.py +55 -0
- viam/gen/service/worldstatestore/v1/world_state_store_pb2.py +39 -0
- viam/gen/service/worldstatestore/v1/world_state_store_pb2.pyi +171 -0
- viam/gen/stream/__init__.py +0 -0
- viam/gen/stream/v1/__init__.py +0 -0
- viam/gen/stream/v1/stream_grpc.py +59 -0
- viam/gen/stream/v1/stream_pb2.py +39 -0
- viam/gen/stream/v1/stream_pb2.pyi +161 -0
- viam/gen/tagger/v1/tagger_pb2.py +9 -8
- viam/logging.py +160 -17
- viam/media/__init__.py +0 -9
- viam/media/audio.py +22 -10
- viam/media/utils/__init__.py +0 -0
- viam/media/utils/pil/__init__.py +55 -0
- viam/media/{viam_rgba_plugin.py → utils/pil/viam_rgba_plugin.py} +10 -16
- viam/media/viam_rgba.py +10 -0
- viam/media/video.py +197 -73
- viam/module/module.py +191 -44
- viam/module/resource_data_consumer.py +41 -0
- viam/module/service.py +9 -1
- viam/module/types.py +4 -5
- viam/operations.py +4 -3
- viam/proto/app/__init__.py +361 -5
- viam/proto/app/agent/__init__.py +28 -0
- viam/proto/app/billing.py +51 -27
- viam/proto/app/cloudslam/__init__.py +48 -0
- viam/proto/app/data/__init__.py +103 -17
- viam/proto/app/datapipelines/__init__.py +56 -0
- viam/proto/app/dataset/__init__.py +40 -0
- viam/proto/app/datasync/__init__.py +11 -5
- viam/proto/app/end_user.py +34 -0
- viam/proto/app/mlinference/__init__.py +15 -0
- viam/proto/app/mltraining/__init__.py +25 -1
- viam/proto/app/packages/__init__.py +3 -3
- viam/proto/app/robot.py +19 -1
- viam/proto/common/__init__.py +35 -8
- viam/proto/component/arm/__init__.py +9 -1
- viam/proto/component/audioin/__init__.py +16 -0
- viam/proto/component/audioinput/__init__.py +3 -1
- viam/proto/component/audioout/__init__.py +15 -0
- viam/proto/component/base/__init__.py +7 -1
- viam/proto/component/board/__init__.py +13 -5
- viam/proto/component/button/__init__.py +15 -0
- viam/proto/component/camera/__init__.py +9 -1
- viam/proto/component/encoder/__init__.py +3 -1
- viam/proto/component/gantry/__init__.py +7 -1
- viam/proto/component/generic/__init__.py +3 -1
- viam/proto/component/gripper/__init__.py +7 -1
- viam/proto/component/inputcontroller/__init__.py +7 -1
- viam/proto/component/motor/__init__.py +7 -1
- viam/proto/component/movementsensor/__init__.py +7 -1
- viam/proto/component/posetracker/__init__.py +7 -1
- viam/proto/component/powersensor/__init__.py +30 -0
- viam/proto/component/sensor/__init__.py +3 -4
- viam/proto/component/servo/__init__.py +3 -1
- viam/proto/component/switch/__init__.py +26 -0
- viam/proto/component/testecho/__init__.py +3 -1
- viam/proto/module/__init__.py +3 -1
- viam/proto/opentelemetry/__init__.py +0 -0
- viam/proto/opentelemetry/proto/__init__.py +0 -0
- viam/proto/opentelemetry/proto/common/__init__.py +15 -0
- viam/proto/opentelemetry/proto/resource/__init__.py +10 -0
- viam/proto/opentelemetry/proto/trace/__init__.py +15 -0
- viam/proto/provisioning/__init__.py +42 -0
- viam/proto/robot/__init__.py +57 -9
- viam/proto/rpc/auth.py +11 -1
- viam/proto/rpc/examples/echo/__init__.py +3 -1
- viam/proto/rpc/examples/echoresource/__init__.py +7 -1
- viam/proto/rpc/webrtc/grpc.py +3 -1
- viam/proto/rpc/webrtc/signaling.py +5 -1
- viam/proto/service/datamanager/__init__.py +15 -2
- viam/proto/service/discovery/__init__.py +15 -0
- viam/proto/service/generic/__init__.py +12 -0
- viam/proto/service/mlmodel/__init__.py +27 -1
- viam/proto/service/motion/__init__.py +35 -5
- viam/proto/service/navigation/__init__.py +19 -1
- viam/proto/service/sensors/__init__.py +3 -1
- viam/proto/service/shell/__init__.py +25 -2
- viam/proto/service/slam/__init__.py +13 -1
- viam/proto/service/video/__init__.py +15 -0
- viam/proto/service/vision/__init__.py +11 -1
- viam/proto/service/worldstatestore/__init__.py +32 -0
- viam/proto/stream/__init__.py +36 -0
- viam/py.typed +0 -0
- viam/resource/base.py +45 -8
- viam/resource/easy_resource.py +149 -0
- viam/resource/manager.py +35 -14
- viam/resource/registry.py +40 -52
- viam/resource/rpc_client_base.py +33 -1
- viam/resource/rpc_service_base.py +15 -8
- viam/resource/types.py +39 -26
- viam/robot/client.py +458 -91
- viam/robot/service.py +13 -107
- viam/rpc/dial.py +133 -15
- viam/rpc/libviam_rust_utils.so +0 -0
- viam/rpc/server.py +59 -15
- viam/rpc/types.py +2 -4
- viam/services/discovery/__init__.py +12 -0
- viam/services/discovery/client.py +55 -0
- viam/services/discovery/discovery.py +52 -0
- viam/services/discovery/service.py +43 -0
- viam/services/generic/__init__.py +18 -0
- viam/services/generic/client.py +58 -0
- viam/services/generic/generic.py +58 -0
- viam/services/generic/service.py +29 -0
- viam/services/mlmodel/__init__.py +15 -1
- viam/services/mlmodel/client.py +20 -15
- viam/services/mlmodel/mlmodel.py +44 -7
- viam/services/mlmodel/service.py +9 -13
- viam/services/mlmodel/utils.py +101 -0
- viam/services/motion/__init__.py +15 -3
- viam/services/motion/client.py +109 -150
- viam/services/motion/motion.py +380 -0
- viam/services/motion/service.py +132 -0
- viam/services/navigation/__init__.py +11 -0
- viam/services/navigation/client.py +99 -0
- viam/services/navigation/navigation.py +250 -0
- viam/services/navigation/service.py +137 -0
- viam/services/service_base.py +43 -4
- viam/services/service_client_base.py +4 -4
- viam/services/slam/__init__.py +4 -1
- viam/services/slam/client.py +21 -11
- viam/services/slam/service.py +16 -19
- viam/services/slam/slam.py +66 -5
- viam/services/vision/__init__.py +8 -0
- viam/services/vision/client.py +115 -111
- viam/services/vision/service.py +143 -0
- viam/services/vision/vision.py +317 -0
- viam/services/worldstatestore/__init__.py +18 -0
- viam/services/worldstatestore/client.py +94 -0
- viam/services/worldstatestore/service.py +55 -0
- viam/services/worldstatestore/worldstatestore.py +90 -0
- viam/sessions_client.py +254 -0
- viam/streams.py +44 -0
- viam/utils.py +143 -15
- viam/version_metadata.py +4 -0
- viam_sdk-0.66.0.dist-info/METADATA +157 -0
- viam_sdk-0.66.0.dist-info/RECORD +531 -0
- {viam_sdk-0.3.0.dist-info → viam_sdk-0.66.0.dist-info}/WHEEL +1 -1
- viam/components/audio_input/__init__.py +0 -18
- viam/components/audio_input/audio_input.py +0 -79
- viam/components/audio_input/client.py +0 -60
- viam/components/audio_input/service.py +0 -118
- viam/components/types.py +0 -5
- viam/gen/app/model/v1/model_grpc.py +0 -39
- viam/gen/app/model/v1/model_pb2.py +0 -71
- viam/gen/app/model/v1/model_pb2.pyi +0 -285
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_grpc.py +0 -21
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.py +0 -18
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.pyi +0 -49
- viam/media/media.py +0 -53
- viam/proto/app/model/__init__.py +0 -40
- viam/proto/rpc/examples/fileupload/__init__.py +0 -13
- viam/services/sensors/__init__.py +0 -5
- viam/services/sensors/client.py +0 -63
- viam_sdk-0.3.0.dist-info/LICENSE +0 -202
- viam_sdk-0.3.0.dist-info/METADATA +0 -122
- viam_sdk-0.3.0.dist-info/RECORD +0 -372
- /viam/{gen/app/model → app}/__init__.py +0 -0
- /viam/gen/app/{model/v1 → agent}/__init__.py +0 -0
- /viam/gen/{proto/rpc/examples/fileupload → app/agent/v1}/__init__.py +0 -0
- /viam/gen/{proto/rpc/examples/fileupload/v1 → app/cloudslam}/__init__.py +0 -0
- /LICENSE → /viam_sdk-0.66.0.dist-info/licenses/LICENSE +0 -0
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
@generated by Viam.
|
|
3
3
|
Do not edit manually!
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
from ....gen.service.slam.v1.slam_grpc import SLAMServiceBase, SLAMServiceStub, UnimplementedSLAMServiceBase
|
|
6
7
|
from ....gen.service.slam.v1.slam_pb2 import (
|
|
7
8
|
GetInternalStateRequest,
|
|
8
9
|
GetInternalStateResponse,
|
|
@@ -10,15 +11,26 @@ from ....gen.service.slam.v1.slam_pb2 import (
|
|
|
10
11
|
GetPointCloudMapResponse,
|
|
11
12
|
GetPositionRequest,
|
|
12
13
|
GetPositionResponse,
|
|
14
|
+
GetPropertiesRequest,
|
|
15
|
+
GetPropertiesResponse,
|
|
16
|
+
MappingMode,
|
|
17
|
+
SensorInfo,
|
|
18
|
+
SensorType,
|
|
13
19
|
)
|
|
14
20
|
|
|
15
21
|
__all__ = [
|
|
16
22
|
"SLAMServiceBase",
|
|
17
23
|
"SLAMServiceStub",
|
|
24
|
+
"UnimplementedSLAMServiceBase",
|
|
18
25
|
"GetInternalStateRequest",
|
|
19
26
|
"GetInternalStateResponse",
|
|
20
27
|
"GetPointCloudMapRequest",
|
|
21
28
|
"GetPointCloudMapResponse",
|
|
22
29
|
"GetPositionRequest",
|
|
23
30
|
"GetPositionResponse",
|
|
31
|
+
"GetPropertiesRequest",
|
|
32
|
+
"GetPropertiesResponse",
|
|
33
|
+
"MappingMode",
|
|
34
|
+
"SensorInfo",
|
|
35
|
+
"SensorType",
|
|
24
36
|
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@generated by Viam.
|
|
3
|
+
Do not edit manually!
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ....gen.service.video.v1.video_grpc import UnimplementedVideoServiceBase, VideoServiceBase, VideoServiceStub
|
|
7
|
+
from ....gen.service.video.v1.video_pb2 import GetVideoRequest, GetVideoResponse
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"UnimplementedVideoServiceBase",
|
|
11
|
+
"VideoServiceBase",
|
|
12
|
+
"VideoServiceStub",
|
|
13
|
+
"GetVideoRequest",
|
|
14
|
+
"GetVideoResponse",
|
|
15
|
+
]
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
@generated by Viam.
|
|
3
3
|
Do not edit manually!
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
from ....gen.service.vision.v1.vision_grpc import UnimplementedVisionServiceBase, VisionServiceBase, VisionServiceStub
|
|
6
7
|
from ....gen.service.vision.v1.vision_pb2 import (
|
|
8
|
+
CaptureAllFromCameraRequest,
|
|
9
|
+
CaptureAllFromCameraResponse,
|
|
7
10
|
Classification,
|
|
8
11
|
Detection,
|
|
9
12
|
GetClassificationsFromCameraRequest,
|
|
@@ -16,11 +19,16 @@ from ....gen.service.vision.v1.vision_pb2 import (
|
|
|
16
19
|
GetDetectionsResponse,
|
|
17
20
|
GetObjectPointCloudsRequest,
|
|
18
21
|
GetObjectPointCloudsResponse,
|
|
22
|
+
GetPropertiesRequest,
|
|
23
|
+
GetPropertiesResponse,
|
|
19
24
|
)
|
|
20
25
|
|
|
21
26
|
__all__ = [
|
|
27
|
+
"UnimplementedVisionServiceBase",
|
|
22
28
|
"VisionServiceBase",
|
|
23
29
|
"VisionServiceStub",
|
|
30
|
+
"CaptureAllFromCameraRequest",
|
|
31
|
+
"CaptureAllFromCameraResponse",
|
|
24
32
|
"Classification",
|
|
25
33
|
"Detection",
|
|
26
34
|
"GetClassificationsFromCameraRequest",
|
|
@@ -33,4 +41,6 @@ __all__ = [
|
|
|
33
41
|
"GetDetectionsResponse",
|
|
34
42
|
"GetObjectPointCloudsRequest",
|
|
35
43
|
"GetObjectPointCloudsResponse",
|
|
44
|
+
"GetPropertiesRequest",
|
|
45
|
+
"GetPropertiesResponse",
|
|
36
46
|
]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@generated by Viam.
|
|
3
|
+
Do not edit manually!
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ....gen.service.worldstatestore.v1.world_state_store_grpc import (
|
|
7
|
+
UnimplementedWorldStateStoreServiceBase,
|
|
8
|
+
WorldStateStoreServiceBase,
|
|
9
|
+
WorldStateStoreServiceStub,
|
|
10
|
+
)
|
|
11
|
+
from ....gen.service.worldstatestore.v1.world_state_store_pb2 import (
|
|
12
|
+
GetTransformRequest,
|
|
13
|
+
GetTransformResponse,
|
|
14
|
+
ListUUIDsRequest,
|
|
15
|
+
ListUUIDsResponse,
|
|
16
|
+
StreamTransformChangesRequest,
|
|
17
|
+
StreamTransformChangesResponse,
|
|
18
|
+
TransformChangeType,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"UnimplementedWorldStateStoreServiceBase",
|
|
23
|
+
"WorldStateStoreServiceBase",
|
|
24
|
+
"WorldStateStoreServiceStub",
|
|
25
|
+
"GetTransformRequest",
|
|
26
|
+
"GetTransformResponse",
|
|
27
|
+
"ListUUIDsRequest",
|
|
28
|
+
"ListUUIDsResponse",
|
|
29
|
+
"StreamTransformChangesRequest",
|
|
30
|
+
"StreamTransformChangesResponse",
|
|
31
|
+
"TransformChangeType",
|
|
32
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@generated by Viam.
|
|
3
|
+
Do not edit manually!
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ...gen.stream.v1.stream_grpc import StreamServiceBase, StreamServiceStub, UnimplementedStreamServiceBase
|
|
7
|
+
from ...gen.stream.v1.stream_pb2 import (
|
|
8
|
+
AddStreamRequest,
|
|
9
|
+
AddStreamResponse,
|
|
10
|
+
GetStreamOptionsRequest,
|
|
11
|
+
GetStreamOptionsResponse,
|
|
12
|
+
ListStreamsRequest,
|
|
13
|
+
ListStreamsResponse,
|
|
14
|
+
RemoveStreamRequest,
|
|
15
|
+
RemoveStreamResponse,
|
|
16
|
+
Resolution,
|
|
17
|
+
SetStreamOptionsRequest,
|
|
18
|
+
SetStreamOptionsResponse,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"StreamServiceBase",
|
|
23
|
+
"StreamServiceStub",
|
|
24
|
+
"UnimplementedStreamServiceBase",
|
|
25
|
+
"AddStreamRequest",
|
|
26
|
+
"AddStreamResponse",
|
|
27
|
+
"GetStreamOptionsRequest",
|
|
28
|
+
"GetStreamOptionsResponse",
|
|
29
|
+
"ListStreamsRequest",
|
|
30
|
+
"ListStreamsResponse",
|
|
31
|
+
"RemoveStreamRequest",
|
|
32
|
+
"RemoveStreamResponse",
|
|
33
|
+
"Resolution",
|
|
34
|
+
"SetStreamOptionsRequest",
|
|
35
|
+
"SetStreamOptionsResponse",
|
|
36
|
+
]
|
viam/py.typed
ADDED
|
File without changes
|
viam/resource/base.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from abc import
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from logging import Logger
|
|
2
3
|
from typing import TYPE_CHECKING, Any, ClassVar, Mapping, Optional, Protocol, runtime_checkable
|
|
3
4
|
|
|
4
5
|
from typing_extensions import Self
|
|
@@ -6,7 +7,7 @@ from typing_extensions import Self
|
|
|
6
7
|
from viam.operations import Operation
|
|
7
8
|
from viam.proto.common import ResourceName
|
|
8
9
|
|
|
9
|
-
from .types import
|
|
10
|
+
from .types import API
|
|
10
11
|
|
|
11
12
|
if TYPE_CHECKING:
|
|
12
13
|
from viam.robot.client import RobotClient
|
|
@@ -19,31 +20,48 @@ class ResourceBase(Protocol):
|
|
|
19
20
|
The base requirements for a Resource.
|
|
20
21
|
"""
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
"""The
|
|
23
|
+
API: ClassVar["API"]
|
|
24
|
+
"""The API of the Resource"""
|
|
24
25
|
|
|
25
26
|
name: str
|
|
26
27
|
"""The name of the Resource"""
|
|
27
28
|
|
|
29
|
+
logger: Logger
|
|
30
|
+
"""A logger allowing for setting log levels on a per-resource basis"""
|
|
31
|
+
|
|
28
32
|
@classmethod
|
|
29
33
|
def get_resource_name(cls, name: str) -> ResourceName:
|
|
30
34
|
"""
|
|
31
35
|
Get the ResourceName for this Resource with the given name
|
|
32
36
|
|
|
37
|
+
::
|
|
38
|
+
|
|
39
|
+
# Can be used with any resource, using an arm as an example
|
|
40
|
+
my_arm_name = Arm.get_resource_name("my_arm")
|
|
41
|
+
|
|
33
42
|
Args:
|
|
34
43
|
name (str): The name of the Resource
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
ResourceName: The ResourceName of this Resource
|
|
35
47
|
"""
|
|
36
48
|
return ResourceName(
|
|
37
|
-
namespace=cls.
|
|
38
|
-
type=cls.
|
|
39
|
-
subtype=cls.
|
|
49
|
+
namespace=cls.API.namespace,
|
|
50
|
+
type=cls.API.resource_type,
|
|
51
|
+
subtype=cls.API.resource_subtype,
|
|
40
52
|
name=name,
|
|
41
53
|
)
|
|
42
54
|
|
|
43
|
-
@
|
|
55
|
+
@classmethod
|
|
56
|
+
@abstractmethod
|
|
44
57
|
def from_robot(cls, robot: "RobotClient", name: str) -> Self:
|
|
45
58
|
"""Get the Resource named ``name`` from the provided robot.
|
|
46
59
|
|
|
60
|
+
::
|
|
61
|
+
|
|
62
|
+
# Can be used with any resource, using an arm as an example
|
|
63
|
+
my_arm = Arm.from_robot(robot, "my_arm")
|
|
64
|
+
|
|
47
65
|
Args:
|
|
48
66
|
robot (RobotClient): The robot
|
|
49
67
|
name (str): The name of the Resource
|
|
@@ -59,6 +77,11 @@ class ResourceBase(Protocol):
|
|
|
59
77
|
) -> Mapping[str, "ValueTypes"]:
|
|
60
78
|
"""Send/Receive arbitrary commands to the Resource
|
|
61
79
|
|
|
80
|
+
::
|
|
81
|
+
|
|
82
|
+
command = {"cmd": "test", "data1": 500}
|
|
83
|
+
result = await component.do_command(command)
|
|
84
|
+
|
|
62
85
|
Args:
|
|
63
86
|
command (Mapping[str, ValueTypes]): The command to execute
|
|
64
87
|
|
|
@@ -84,3 +107,17 @@ class ResourceBase(Protocol):
|
|
|
84
107
|
viam.operations.Operation: The operation associated with this function
|
|
85
108
|
"""
|
|
86
109
|
return kwargs.get(Operation.ARG_NAME, Operation._noop())
|
|
110
|
+
|
|
111
|
+
async def close(self):
|
|
112
|
+
"""Safely shut down the resource and prevent further use.
|
|
113
|
+
|
|
114
|
+
Close must be idempotent. Later configuration may allow a resource to be "open" again.
|
|
115
|
+
If a resource does not want or need a close function, it is assumed that the resource does not need to return errors when future
|
|
116
|
+
non-Close methods are called.
|
|
117
|
+
|
|
118
|
+
::
|
|
119
|
+
|
|
120
|
+
await component.close()
|
|
121
|
+
|
|
122
|
+
"""
|
|
123
|
+
return
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import re
|
|
3
|
+
from abc import ABCMeta
|
|
4
|
+
from typing import Callable, ClassVar, Mapping, Sequence, Tuple, Union
|
|
5
|
+
|
|
6
|
+
from viam.proto.app.robot import ComponentConfig
|
|
7
|
+
from viam.proto.common import ResourceName
|
|
8
|
+
|
|
9
|
+
from .. import logging
|
|
10
|
+
from ..errors import MethodNotImplementedError
|
|
11
|
+
from .base import ResourceBase
|
|
12
|
+
from .registry import Registry, ResourceCreatorRegistration
|
|
13
|
+
from .types import API, Model, ModelFamily
|
|
14
|
+
|
|
15
|
+
modelRegex = re.compile(r"^([^:]+):([^:]+):([^:]+)$")
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _parse_model(orig: Union[str, Model]) -> Model:
|
|
21
|
+
"take a model or string and turn it into a Model"
|
|
22
|
+
if isinstance(orig, Model):
|
|
23
|
+
return orig
|
|
24
|
+
match = modelRegex.match(orig)
|
|
25
|
+
if not match:
|
|
26
|
+
raise ValueError(f"MODEL {orig} doesn't match expected format 'org:type:name'")
|
|
27
|
+
*family, name = match.groups()
|
|
28
|
+
return Model(ModelFamily(*family), name)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _create_stub_fn(name: str, is_async: bool) -> Callable:
|
|
32
|
+
"""
|
|
33
|
+
This creates a sync or async stub function which returns a MethodNotImplementedError.
|
|
34
|
+
The stub_model decorator uses these to stub out an abstract base class.
|
|
35
|
+
"""
|
|
36
|
+
if is_async:
|
|
37
|
+
# note: this is a pyright bug https://github.com/microsoft/pyright/issues/2136
|
|
38
|
+
async def stub_fn(*args, **kwargs): # pyright: ignore [reportRedeclaration]
|
|
39
|
+
logger.info(f"{name} not implemented")
|
|
40
|
+
raise MethodNotImplementedError(name)
|
|
41
|
+
|
|
42
|
+
else:
|
|
43
|
+
|
|
44
|
+
def stub_fn(*args, **kwargs):
|
|
45
|
+
logger.info(f"{name} not implemented")
|
|
46
|
+
raise MethodNotImplementedError(name)
|
|
47
|
+
|
|
48
|
+
stub_fn.__name__ = f"{name}_stub"
|
|
49
|
+
return stub_fn
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def stub_model(cls: ABCMeta) -> ABCMeta:
|
|
53
|
+
"""
|
|
54
|
+
Class decorator which adds error implementations of abstract functions. This means they will fail
|
|
55
|
+
when called, rather than the default where they fail when instantiated. This is intended for developers
|
|
56
|
+
who want to build and test incrementally, not for production use.
|
|
57
|
+
|
|
58
|
+
Example:
|
|
59
|
+
|
|
60
|
+
@stub_model
|
|
61
|
+
class MyMotor(Motor, EasyResource):
|
|
62
|
+
MODEL = 'viam:motor:easy-resource-example'
|
|
63
|
+
|
|
64
|
+
Normally this class would fail to instantiate. With the decorator, it will succeed but the unimplemented
|
|
65
|
+
methods will throw errors at runtime.
|
|
66
|
+
"""
|
|
67
|
+
for attr in list(cls.__abstractmethods__):
|
|
68
|
+
val = getattr(cls, attr)
|
|
69
|
+
is_async = inspect.iscoroutinefunction(val)
|
|
70
|
+
stub_fn = _create_stub_fn(attr, is_async)
|
|
71
|
+
setattr(cls, attr, stub_fn)
|
|
72
|
+
logger.debug("patched %s.%s with %s", cls, attr, stub_fn)
|
|
73
|
+
cls.__abstractmethods__ -= {attr}
|
|
74
|
+
return cls
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class EasyResource:
|
|
78
|
+
"""
|
|
79
|
+
EasyResource is a mixin that simplifies the process of creating Viam modules (extension programs)
|
|
80
|
+
and resources (the resource classes provided by those extension programs).
|
|
81
|
+
|
|
82
|
+
Basic usage:
|
|
83
|
+
|
|
84
|
+
::
|
|
85
|
+
|
|
86
|
+
class MyModel(Sensor, EasyResource):
|
|
87
|
+
MODEL = "my-org:sensor:my-sensor"
|
|
88
|
+
|
|
89
|
+
async def get_readings(self, **kwargs):
|
|
90
|
+
return {"ok": True}
|
|
91
|
+
|
|
92
|
+
See examples/easy_resource/main.py for extended usage.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
API: ClassVar[API]
|
|
96
|
+
MODEL: ClassVar[Model]
|
|
97
|
+
|
|
98
|
+
def __init_subclass__(cls, register=True, **kwargs):
|
|
99
|
+
"""
|
|
100
|
+
When you subclass this mixin, it parses cls.MODEL and registers cls in global registry.
|
|
101
|
+
"""
|
|
102
|
+
super().__init_subclass__(**kwargs)
|
|
103
|
+
if not hasattr(cls, "MODEL"):
|
|
104
|
+
raise ValueError("Please define a MODEL with the format 'org:type:name' on your class, for example 'viam:camera:IMX219'")
|
|
105
|
+
cls.MODEL = _parse_model(cls.MODEL)
|
|
106
|
+
if register:
|
|
107
|
+
cls.register()
|
|
108
|
+
|
|
109
|
+
def __init__(self, name: str):
|
|
110
|
+
# note: this mirrors the constructor for ComponentBase and ServiceBase.
|
|
111
|
+
self.name = name
|
|
112
|
+
|
|
113
|
+
@classmethod
|
|
114
|
+
def new(cls, config: ComponentConfig, dependencies: Mapping[ResourceName, ResourceBase]):
|
|
115
|
+
"""
|
|
116
|
+
This is passed to register_resource_creator. The default implementation only sets the resource name
|
|
117
|
+
when an instance of your model is instantiated. You can override this in your subclass.
|
|
118
|
+
"""
|
|
119
|
+
self = cls(config.name)
|
|
120
|
+
logger.debug("created %s %s %s", cls.API, cls.MODEL, config.name)
|
|
121
|
+
return self
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
def validate_config(cls, config: ComponentConfig) -> Tuple[Sequence[str], Sequence[str]]:
|
|
125
|
+
"""This method allows you to validate the configuration object received from the machine,
|
|
126
|
+
as well as to return any implicit dependencies based on that `config`.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
config (ComponentConfig): The configuration for this resource
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
Tuple[Sequence[str], Sequence[str]]: One list of required implicit dependencies and one of optional deps.
|
|
133
|
+
"""
|
|
134
|
+
return [], []
|
|
135
|
+
|
|
136
|
+
@classmethod
|
|
137
|
+
def register(cls):
|
|
138
|
+
"""
|
|
139
|
+
This adds the model to the global registry. It is called by __init_subclass__ and you typically
|
|
140
|
+
won't call it directly.
|
|
141
|
+
"""
|
|
142
|
+
logger.debug("registering %s %s", cls.API, cls.MODEL)
|
|
143
|
+
# note: We could fix this pyright-ignore if EasyResource inherited ResourceBase, but that crashes in the mro()
|
|
144
|
+
# walk in ResourceManager.register.
|
|
145
|
+
Registry.register_resource_creator(
|
|
146
|
+
cls.API,
|
|
147
|
+
cls.MODEL,
|
|
148
|
+
ResourceCreatorRegistration(cls.new, cls.validate_config), # pyright: ignore [reportArgumentType]
|
|
149
|
+
)
|
viam/resource/manager.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
2
|
from typing import Dict, List, Type, TypeVar
|
|
3
3
|
|
|
4
|
+
from viam.logging import getLogger
|
|
4
5
|
from viam.proto.common import ResourceName
|
|
5
6
|
from viam.resource.base import ResourceBase
|
|
6
7
|
from viam.resource.registry import Registry
|
|
@@ -9,6 +10,7 @@ from ..components.component_base import ComponentBase
|
|
|
9
10
|
from ..errors import DuplicateResourceError, ResourceNotFoundError
|
|
10
11
|
from ..services.service_base import ServiceBase
|
|
11
12
|
|
|
13
|
+
LOGGER = getLogger(__name__)
|
|
12
14
|
ResourceType = TypeVar("ResourceType", bound=ResourceBase)
|
|
13
15
|
|
|
14
16
|
|
|
@@ -28,29 +30,30 @@ class ResourceManager:
|
|
|
28
30
|
for component in components:
|
|
29
31
|
self.register(component)
|
|
30
32
|
|
|
31
|
-
def register(self,
|
|
33
|
+
def register(self, resource: ResourceBase):
|
|
32
34
|
"""
|
|
33
|
-
Register a new
|
|
34
|
-
|
|
35
|
-
If a
|
|
35
|
+
Register a new resource with the registry.
|
|
36
|
+
Resources may not have the same name.
|
|
37
|
+
If a resource is remote and the short name is unique, save a short name version.
|
|
36
38
|
|
|
37
39
|
Raises:
|
|
38
|
-
|
|
39
|
-
with the name of an existing
|
|
40
|
+
DuplicateResourceError: Error if attempting to register resource
|
|
41
|
+
with the name of an existing resource
|
|
42
|
+
ResourceNotFoundError: Raised if the API of the resource is not registered
|
|
40
43
|
|
|
41
44
|
Args:
|
|
42
|
-
|
|
45
|
+
resource (ResourceBase): The resource to register
|
|
43
46
|
"""
|
|
44
|
-
Registry.
|
|
47
|
+
Registry.lookup_api(resource.API) # confirm the API is registered in Registry
|
|
45
48
|
|
|
46
49
|
_BaseClasses = (ResourceBase, ComponentBase, ServiceBase)
|
|
47
50
|
rnames: Dict[ResourceName, ResourceBase] = {}
|
|
48
|
-
for subtype in
|
|
51
|
+
for subtype in resource.__class__.mro():
|
|
49
52
|
if subtype in _BaseClasses:
|
|
50
53
|
continue
|
|
51
54
|
if hasattr(subtype, "get_resource_name"):
|
|
52
|
-
rn = subtype.get_resource_name(
|
|
53
|
-
rnames[rn] =
|
|
55
|
+
rn = subtype.get_resource_name(resource.name) # type: ignore
|
|
56
|
+
rnames[rn] = resource
|
|
54
57
|
for rn in rnames:
|
|
55
58
|
if ":" in rn.name:
|
|
56
59
|
short_name = rn.name.split(":")[-1]
|
|
@@ -60,7 +63,7 @@ class ResourceManager:
|
|
|
60
63
|
self._short_to_long_name[short_name] = [rn]
|
|
61
64
|
|
|
62
65
|
if rnames.keys() & self.resources.keys():
|
|
63
|
-
raise DuplicateResourceError(
|
|
66
|
+
raise DuplicateResourceError(resource.name)
|
|
64
67
|
|
|
65
68
|
with self._lock:
|
|
66
69
|
self.resources.update(rnames)
|
|
@@ -90,14 +93,32 @@ class ResourceManager:
|
|
|
90
93
|
return self.get_resource(of_type, self._short_to_long_name[name.name][0])
|
|
91
94
|
raise ResourceNotFoundError(name.subtype, name.name)
|
|
92
95
|
|
|
93
|
-
def remove_resource(self, name: ResourceName):
|
|
96
|
+
async def remove_resource(self, name: ResourceName):
|
|
94
97
|
"""Remove the resource with the specified ```ResourceName```.
|
|
95
98
|
|
|
96
99
|
Args:
|
|
97
100
|
name (viam.proto.common.ResourceName): The ResourceName of the resource
|
|
98
101
|
"""
|
|
99
102
|
with self._lock:
|
|
100
|
-
|
|
103
|
+
try:
|
|
104
|
+
resource = self.resources[name]
|
|
105
|
+
await resource.close()
|
|
106
|
+
finally:
|
|
107
|
+
try:
|
|
108
|
+
del self.resources[name]
|
|
109
|
+
except KeyError:
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
async def close(self):
|
|
113
|
+
"""Close the resourcce manager by removing all resources.
|
|
114
|
+
Please note that any errors will not raise an exception. Errors will still be logged."""
|
|
115
|
+
rns = [key for key in self.resources.keys()]
|
|
116
|
+
with self._lock:
|
|
117
|
+
for rn in rns:
|
|
118
|
+
try:
|
|
119
|
+
await self.remove_resource(rn)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
LOGGER.error(f"Error while closing {rn.name}:", e)
|
|
101
122
|
|
|
102
123
|
def _resource_by_name_only(self, name: str) -> ResourceBase:
|
|
103
124
|
for rname, resource in self.resources.items():
|