- Replaced custom transition creation functions with a centralized `create_transition` function imported from converters across multiple test files.
- Updated test cases to utilize keyword arguments for better readability and maintainability, ensuring consistent transition creation throughout the test suite.
- Updated the type annotations for the preprocessor and postprocessor parameters in the eval_policy function to use PolicyProcessorPipeline with a dictionary type, enhancing type safety and clarity in the evaluation process.
* refactor(processor): signature of transform_features
* refactor(processor): remove prefixes + processor respect new transform_features signature + update test accordingly
* refactor(processor): rename now is only for visual
* refactor(processor): update normalize processor
* refactor(processor): update vanilla processor features
* refactor(processor): feature contract now uses its own enum
* chore(processor): rename renameprocessor
* chore(processor): minor changes
* refactor(processor): add create & change aggregate
* refactor(processor): update aggregate
* refactor(processor): simplify to functions, fix features contracts and rename function
* test(processor): remove to converter tests as now they are very simple
* chore(docs): recover docs joint observations processor
* fix(processor): update RKP
* fix(tests): recv diff test_pipeline
* chore(tests): add docs to test
* chore(processor): leave obs language constant untouched
* fix(processor): correct new shape of feature in crop image processor
- Updated the function name from _from_tensor to from_tensor_to_numpy to better reflect its purpose of converting PyTorch tensors to numpy arrays or scalars.
- Adjusted all references to the renamed function throughout the codebase to maintain consistency.
- Enhanced the _NormalizationMixin class to reconstruct the stats dictionary from tensor stats using the new function, ensuring compatibility after loading state dicts.
- Added tests to verify the correct reconstruction of stats and functionality of methods dependent on self.stats after loading.
* refactor(eval): integrate preprocessor and postprocessor into rollout and eval_policy functions
- Updated the `rollout` and `eval_policy` functions to accept preprocessor and postprocessor parameters, enhancing the flexibility of the evaluation pipeline.
- Adjusted the implementation to apply preprocessing and postprocessing steps during policy evaluation, improving the overall data handling and processing flow.
* refactor(eval): remove redundant observation device conversion in rollout function
- Eliminated unnecessary device conversion for the observation dictionary within the `rollout` function, streamlining the code and enhancing readability.
- This change simplifies the observation handling process, aligning with the preference for clearer solutions.
* debug
* refactor(utils): enhance task handling in add_envs_task function
- Improved the `add_envs_task` function to validate the output of `task_description` and `task` calls, ensuring they return lists of strings.
- Removed the use of `else` statement for environments without language instructions, simplifying the logic and enhancing readability.
- Streamlined the observation dictionary handling by ensuring consistent data types for task attributes.
* refactor(processors): reorder processor steps for consistency across implementations
- Updated the order of processor steps in multiple files to ensure consistency, placing AddBatchDimensionProcessorStep and DeviceProcessorStep before NormalizerProcessorStep.
- Adjusted related test assertions to reflect the new order of steps in the preprocessor, enhancing clarity and maintainability.
* refactor(normalization): remove dtype specification in tensor conversion for adaptation logic
- Updated tensor conversion in the _NormalizationMixin class to remove explicit dtype specification, allowing for automatic adaptation of tensor types.
- Adjusted related tests to ensure proper functionality with the new tensor conversion logic, verifying that normalizers adapt correctly to input types.
* Remove unused max_relative_target for stretch3
* Fix type annotation and allow integer max_relative_target values
* Configure max_relative_target to be floats instead of ints
* Update docs and types to reflect that max_relative_target can be a dict
* Remove unnecessary isinstance check for ints
* Fix typo in name
---------
Co-authored-by: Justin Huang <justin.huang@jpl.nasa.gov>
* refactor(logging): enhance log_rerun_data to handle observation and action separately
- Updated the `log_rerun_data` function to accept and log observation and action data more clearly, improving readability and maintainability.
- Refactored the `record_loop` and `teleop_loop` functions to extract and pass observation and action data to `log_rerun_data`, ensuring consistent logging format.
* refactor(tests): update test_log_rerun_data to align with log_rerun_data changes
- Modified test cases in `test_visualization_utils.py` to extract and pass observation and action data separately to `log_rerun_data`, improving clarity and consistency with recent function updates.
- Ensured that the tests reflect the new structure of `log_rerun_data` for better maintainability.
* refactor(processors): simplify calls to log_rerun + replace lambda functions with identity_transition
---------
Co-authored-by: Steven Palma <steven.palma@huggingface.co>
- Changed assertions in multiple processor test files to verify the updated names from "robot_preprocessor" and "robot_postprocessor" to "policy_preprocessor" and "policy_postprocessor" for consistency with recent refactoring.
- Updated constant names from PREPROCESSOR_DEFAULT_NAME and POSTPROCESSOR_DEFAULT_NAME to POLICY_PREPROCESSOR_DEFAULT_NAME and POLICY_POSTPROCESSOR_DEFAULT_NAME for better context.
- Adjusted references across multiple files to use the new constant names, ensuring consistency in the codebase.
- Added the HasTeleopEvents protocol to define a standard for teleoperators that provide control events.
- Implemented a runtime check to ensure teleoperators implement the get_teleop_events() method.
- Updated AddTeleopEventsAsInfoStep to utilize the new protocol, enhancing compatibility with custom teleoperators.
- Improved documentation for clarity on teleoperation event extraction and compatibility with built-in teleoperators.
- Removed the scipy dependency from the project to streamline requirements.
- Added a new `rotation.py` module containing a custom `Rotation` class that replicates essential functionalities of `scipy.spatial.transform.Rotation`, allowing for rotation vector, matrix, and quaternion conversions without external dependencies.
- Updated the `robot_kinematic_processor.py` to utilize the new custom rotation utilities.
- Updated the DataProcessorPipeline to require that all steps inherit from ProcessorStep, enhancing type safety and clarity.
- Adjusted tests to utilize a MockTokenizerProcessorStep that adheres to the ProcessorStep interface, ensuring consistent behavior across tests.
- Refactored various mock step classes in tests to inherit from ProcessorStep for improved consistency and maintainability.
- Introduced new transition features (`next.reward`, `next.done`, `next.truncated`) in the dataset during recording.
- Updated the `transition_to_dataset_frame` function to handle scalar values correctly, ensuring compatibility with expected array formats for reward, done, and truncated features.
- Updated the DataProcessorPipeline to require a specific config_filename when loading from Hugging Face Hub, enhancing clarity and preventing errors.
- Simplified local path checks and improved error handling for invalid paths.
- Adjusted tests to reflect the new requirement and ensure proper error handling for various loading scenarios.
* feat(processor): introduce PolicyProcessorPipeline and RobotProcessorPipeline as type aliases for DataProcessorPipeline
- Added PolicyProcessorPipeline and RobotProcessorPipeline type aliases to enhance clarity and maintainability in the processor module.
- Updated the __all__ list to include the new pipelines for better module export consistency.
* refactor(processor): replace DataProcessorPipeline with PolicyProcessorPipeline across multiple modules
- Updated all instances of DataProcessorPipeline to PolicyProcessorPipeline in various processor files for consistency and clarity.
- Adjusted function signatures to reflect the new pipeline type, enhancing maintainability and readability.
* refactor(processor): update hotswap_stats function to use PolicyProcessorPipeline
- Changed the parameter name from robot_processor to policy_processor for clarity.
- Ensured consistency with recent updates to the processor module by reflecting the new pipeline type in the function signature.
* refactor(processor): replace DataProcessorPipeline with PolicyProcessorPipeline in migrate_policy_normalization.py
- Updated the preprocessor and postprocessor to use PolicyProcessorPipeline for consistency with recent changes in the processor module.
- Enhanced clarity and maintainability by aligning with the new pipeline structure.
* refactor(processor): update hotswap_stats to use PolicyProcessorPipeline
- Changed the parameter type in hotswap_stats from DataProcessorPipeline to PolicyProcessorPipeline for consistency with recent updates.
- Enhanced clarity by updating the function documentation to reflect the new pipeline type.
* refactor(processor): replace DataProcessorPipeline with RobotProcessorPipeline across multiple files
- Updated instances of DataProcessorPipeline to RobotProcessorPipeline in evaluate.py, record.py, replay.py, teleoperate.py, and other relevant files for consistency and clarity.
- Adjusted function signatures and variable types to reflect the new pipeline structure, enhancing maintainability and readability.
- Changed the internal device variable from `_device` to `tensor_device` for improved readability and consistency.
- Updated references throughout the class to reflect the new variable name.
- Changed the internal tokenizer variable name from `_tokenizer` to `input_tokenizer` for improved readability and consistency.
- Updated references throughout the class to reflect the new variable name.
* refactor(processor): rename MapDeltaActionToRobotAction and MapTensorToDeltaActionDict for consistency
* refactor(processor): rename DeviceProcessor to DeviceProcessorStep for consistency across modules
* refactor(processor): rename Torch2NumpyActionProcessor to Torch2NumpyActionProcessorStep for consistency
* refactor(processor): rename Numpy2TorchActionProcessor to Numpy2TorchActionProcessorStep for consistency
* refactor(processor): rename AddTeleopActionAsComplimentaryData to AddTeleopActionAsComplimentaryDataStep for consistency
* refactor(processor): rename ImageCropResizeProcessor and AddTeleopEventsAsInfo for consistency
* refactor(processor): rename TimeLimitProcessor to TimeLimitProcessorStep for consistency
* refactor(processor): rename GripperPenaltyProcessor to GripperPenaltyProcessorStep for consistency
* refactor(processor): rename InterventionActionProcessor to InterventionActionProcessorStep for consistency
* refactor(processor): rename RewardClassifierProcessor to RewardClassifierProcessorStep for consistency
* refactor(processor): rename JointVelocityProcessor to JointVelocityProcessorStep for consistency
* refactor(processor): rename MotorCurrentProcessor to MotorCurrentProcessorStep for consistency
* refactor(processor): rename NormalizerProcessor and UnnormalizerProcessor to NormalizerProcessorStep and UnnormalizerProcessorStep for consistency
* refactor(processor): rename VanillaObservationProcessor to VanillaObservationProcessorStep for consistency
* refactor(processor): rename RenameProcessor to RenameProcessorStep for consistency
* refactor(processor): rename TokenizerProcessor to TokenizerProcessorStep for consistency
* refactor(processor): rename ToBatchProcessor to AddBatchDimensionProcessorStep for consistency
* refactor(processor): update config file name in test for RenameProcessorStep consistency
* refactor(processors): enhance transform_features method across multiple processors
- Updated the transform_features method in various processors to utilize a copy of the features dictionary, ensuring immutability of the original features.
- Added handling for new feature keys and removed obsolete ones in the MapTensorToDeltaActionDict, JointVelocityProcessor, and others.
- Improved readability and maintainability by following consistent patterns in feature transformation.
* refactor(processors): standardize action and observation keys in delta_action_processor and joint_observations_processor
- Updated action and observation keys to use constants for improved readability and maintainability.
- Refactored the transform_features method in multiple processors to ensure consistent handling of feature keys.
- Enhanced error handling by raising exceptions for missing required components in action and observation processing.
- Removed obsolete code and improved overall structure for better clarity.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* refactor(processors): remove unused import in joint_observations_processor
* refactor(processors): simplify transform_features method in delta_action_processor
* refactor(processors): streamline transform_features method in ImageCropResizeProcessor
* refactor(processors): improve error handling and streamline transform_features method in phone_processor
- Raised a ValueError for missing position and rotation in action to enhance error handling.
* refactor(processors): enhance error handling in JointVelocityProcessor
- Added a ValueError raise for missing current joint positions in the observation method to improve error handling and ensure the integrity of the transform_features method.
* refactor(processors): simplify transform_features method in robot kinematic processors
* refactor(processors): standardize action keys in phone_processor
* fix(processor): RKP feature obs -> act
---------
Signed-off-by: Adil Zouitine <adilzouitinegm@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Steven Palma <steven.palma@huggingface.co>
* refactor(converters): move batch transition functions to converters module
- Moved `_default_batch_to_transition` and `_default_transition_to_batch` functions from `pipeline.py` to `converters.py` for better organization and separation of concerns.
- Updated references in `RobotProcessor` to use the new location of these functions.
- Added tests to ensure correct functionality of the transition functions, including handling of index and task_index fields.
- Removed redundant tests from `pipeline.py` to streamline the test suite.
* refactor(processor): reorganize EnvTransition and TransitionKey definitions
- Moved `EnvTransition` and `TransitionKey` classes from `pipeline.py` to a new `core.py` module for better structure and maintainability.
- Updated import statements across relevant modules to reflect the new location of these definitions, ensuring consistent access throughout the codebase.
* refactor(converters): rename and update dataset frame conversion functions
- Replaced `to_dataset_frame` with `transition_to_dataset_frame` for clarity and consistency in naming.
- Updated references in `record.py`, `pipeline.py`, and tests to use the new function name.
- Introduced `merge_transitions` to streamline the merging of transitions, enhancing readability and maintainability.
- Adjusted related tests to ensure correct functionality with the new naming conventions.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix(processor): solve conflict artefacts
* refactor(converters): remove unused identity function and update type hints for merge_transitions
* refactor(processor): remove unused identity import and clean up gym_manipulator.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Steven Palma <steven.palma@huggingface.co>
- Introduced `to_tensor` function using `singledispatch` to handle various input types, including scalars, arrays, and dictionaries, converting them to PyTorch tensors.
- Replaced previous tensor conversion logic in `gym_action_processor`, `normalize_processor`, and `test_converters` with the new `to_tensor` function for improved readability and maintainability.
- Updated tests to cover new functionality and ensure correct tensor conversion behavior.
Co-authored-by: AdilZouitine <adilzouitinegm@gmail.com>
- Introduced `to_tensor` function using `singledispatch` to handle various input types, including scalars, arrays, and dictionaries, converting them to PyTorch tensors.
- Replaced previous tensor conversion logic in `gym_action_processor`, `normalize_processor`, and `test_converters` with the new `to_tensor` function for improved readability and maintainability.
- Updated tests to cover new functionality and ensure correct tensor conversion behavior.
* refactor(processor): introduce generic type for to_output
- Always return `TOutput`
- Remove `_prepare_transition`, so `__call__` now always returns `TOutput`
- Update tests accordingly
- This refactor paves the way for adding settings for `to_transition` and `to_output` in `make_processor` and the post-processor
* refactor(processor): consolidate ProcessorKwargs usage across policies
- Removed the ProcessorTypes module and integrated ProcessorKwargs directly into the processor pipeline.
- Updated multiple policy files to utilize the new ProcessorKwargs structure for preprocessor and postprocessor arguments.
- Simplified the handling of processor kwargs by initializing them to empty dictionaries when not provided.
- Added new constants for truncated and done states in constants.py.
- Updated references to action and observation keys in pipeline_features.py, converters.py, hil_processor.py, tokenizer_processor.py, and robot_kinematic_processor.py to use the new constants for improved readability and maintainability.
* [Port codebase pipeline] General fixes for RL and scripts (#1748)
* Refactor dataset configuration in documentation and codebase
- Updated dataset configuration keys from `dataset_root` to `root` and `num_episodes` to `num_episodes_to_record` for consistency.
- Adjusted replay episode handling by renaming `episode` to `replay_episode`.
- Enhanced documentation
- added specific processor to transform from policy actions to delta actions
* Added Robot action to tensor processor
Added new processor script for dealing with gym specific action processing
* removed RobotAction2Tensor processor; imrpoved choosing observations in actor
* nit in delta action
* added missing reset functions to kinematics
* Adapt teleoperate and replay to pipeline similar to record
* refactor(processors): move to inheritance (#1750)
* fix(teleoperator): improvements phone implementation (#1752)
* fix(teleoperator): protect shared state in phone implementation
* refactor(teleop): separate classes in phone
* fix: solve breaking changes (#1753)
* refactor(policies): multiple improvements (#1754)
* refactor(processor): simpler logic in device processor (#1755)
* refactor(processor): euclidean distance in delta action processor (#1757)
* refactor(processor): improvements to joint observations processor migration (#1758)
* refactor(processor): improvements to tokenizer migration (#1759)
* refactor(processor): improvements to tokenizer migration
* fix(tests): tokenizer tests regression from #1750
* fix(processors): fix float comparison and config in hil processors (#1760)
* chore(teleop): remove unnecessary callbacks in KeyboardEndEffectorTeleop (#1761)
* refactor(processor): improvements normalize pipeline migration (#1756)
* refactor(processor): several improvements normalize processor step
* refactor(processor): more improvements normalize processor
* refactor(processor): more changes to normalizer
* refactor(processor): take a different approach to DRY
* refactor(processor): final design
* chore(record): revert comment and continue deleted (#1764)
* refactor(examples): pipeline phone examples (#1769)
* refactor(examples): phone teleop + teleop script
* refactor(examples): phone replay + replay
* chore(examples): rename phone example files & folders
* feat(processor): fix improvements to the pipeline porting (#1796)
* refactor(processor): enhance tensor device handling in normalization process (#1795)
* refactor(tests): remove unsupported device detection test for complementary data (#1797)
* chore(tests): update ToBatchProcessor test (#1798)
* refactor(tests): remove in-place mutation tests for actions and complementary data in batch processor
* test(tests): add tests for action and task processing in batch processor
* add names for android and ios phone (#1799)
* use _tensor_stats in normalize processor (#1800)
* fix(normalize_processor): correct device reference for tensor epsilon handling (#1801)
* add point 5 add missing feature contracts (#1806)
* Fix PR comments 1452 (#1807)
* use key to determine image
* Address rest of PR comments
* use PolicyFeatures in transform_features
---------
Co-authored-by: Pepijn <138571049+pkooij@users.noreply.github.com>
---------
Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co>
Co-authored-by: Adil Zouitine <adilzouitinegm@gmail.com>
Co-authored-by: Pepijn <138571049+pkooij@users.noreply.github.com>
The 'episode_data' parameter was previously ignored, causing an error if provided. This change ensures it is correctly used, which allows for asynchronous episode saving by passing a copy of the episode buffer, preventing conflicts with the main data collection loop.