-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance load_states function and add video recording capability #96
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9fc8313
feat: enhance load_states function with validation and add load_state…
ll7 1e4b3e9
feat: remove debug logging for frame recording in SimulationView
ll7 5d3b832
feat: add pytest for load_states_and_record_video function with video…
ll7 f5d7a3e
Update robot_sf/render/playback_recording.py
ll7 632e246
Merge remote-tracking branch 'origin/79-Create-videos-based-on-state-…
ll7 8c940ee
fix: correct typo in video_save_path parameter in load_states_and_rec…
ll7 548945f
feat: enhance documentation for load_states and load_states_and_recor…
ll7 f63521b
feat: improve module docstring for playback recording functionality
ll7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""pytest for load_states_and_record_video.py""" | ||
|
||
import pytest | ||
import datetime | ||
from robot_sf.render.playback_recording import load_states_and_record_video | ||
from robot_sf.render.sim_view import MOVIEPY_AVAILABLE | ||
from pathlib import Path | ||
|
||
|
||
@pytest.mark.skipif( | ||
not MOVIEPY_AVAILABLE, reason="MoviePy/ffmpeg not available for video recording" | ||
) | ||
def test_load_states_and_record_video(delete_video: bool = True): | ||
"""Test loading simulation states and recording them as video. | ||
Args: | ||
delete_video: Whether to delete the video file after test. Default True. | ||
""" | ||
# Create recordings directory if it doesn't exist | ||
recordings_dir = Path("recordings") | ||
recordings_dir.mkdir(exist_ok=True) | ||
|
||
# create a unique video name | ||
video_name = "playback_test_" + datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + ".mp4" | ||
|
||
output_path = recordings_dir / video_name | ||
|
||
try: | ||
load_states_and_record_video( | ||
"test_pygame/recordings/2024-06-04_08-39-59.pkl", str(output_path) | ||
) | ||
|
||
assert output_path.exists(), "Video file was not created" | ||
assert output_path.stat().st_size > 0, "Video file is empty" | ||
finally: | ||
# Clean up | ||
if output_path.exists() and delete_video: | ||
output_path.unlink() | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
test_load_states_and_record_video(delete_video=False) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using a fixture for test data.
The hardcoded test file path "test_pygame/recordings/2024-06-04_08-39-59.pkl" could make the test brittle. Consider: