Refactor/CI: Separate viz scripts and add test infrastructure#3
Merged
Conversation
…dd CLI args - Moves src/generate_svg.py to scripts/visualization/joyplot.py to separate imperative scripts from library code. - Replaces hardcoded file paths and constants with argparse CLI arguments. - Adds standard boilerplate for path handling.
- Adds tests/test_imports.py to verify that the 'src' package can be imported without circular dependency errors.
- Moves plot_health_check() from src/diagnostics.py to src/plots.py to keep diagnostics.py pure logic (Layer 3) and plots.py pure UI (Layer 4). - Removes matplotlib dependency from diagnostics.py to allow headless execution. - Updates src/plots.py imports to include config.
- Moves the visualization logic from scripts/analysis/spectrum.py into src/viz.py as a reusable function `analyze_signal_plot()`. - Flattens scripts/analysis/spectrum.py to remove the `analyze_file` wrapper, making `main()` call the library function directly.
- Adds [tool.ruff] configuration for Python 3.13. - Adds [tool.pytest.ini_options] to locate tests in the subfolder and ensure src/ is importable.
- Creates .github/workflows/ci.yml to run tests and linting on push/PR. - Configures matrix for macOS/Ubuntu and Python 3.13. - Uses uv for fast dependency management.
- scripts/capture/master_transfer.py:
- Replace unused 'osc' variable with '_' in context managers.
- Update deprecated diagnostics.plot_health_check() call to plots.plot_health_check().
- scripts/visualization/render_scope_video.py:
- Rename ambiguous variable 'l' to 'glow_line'.
- Wrap long comment for ffmpeg presets.
- power-regulator/schematic.py:
- Shorten long comment to satisfy line length limit.
7f4a5da to
d370af8
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refactor Visualization Scripts and Add CI Infrastructure
Summary
This PR refactors the project structure to separate library logic (
src/) from imperative scripts (scripts/), specifically targeting visualization tools. It also introduces a formal CI pipeline using GitHub Actions (viauv) and adds basic smoke testing to prevent circular import regressions.Changes
🏗️ Refactoring & Architecture
src/generate_svg.pytoscripts/visualization/joyplot.py: Converted the hardcoded script into a reusable CLI tool withargparse.src/diagnostics.pyinto pure logic (Layer 3) and moved the UI/Plotting code (plot_health_check) tosrc/plots.py(Layer 4). This allows the diagnostics logic to run in headless environments.scripts/analysis/spectrum.pyintosrc/viz.pyasanalyze_signal_plot(), making the script a thin wrapper around the library.🧪 Testing & CI
.github/workflows/ci.ymlto run linting (Ruff) and tests (Pytest) on macOS and Ubuntu (Python 3.13).tests/test_imports.pyto verify the package dependency graph is acyclic and importable.pyproject.tomlwith configuration for Ruff (targeting py313) and Pytest (test discovery).tests/README.mdto document the testing strategy.🧹 Maintenance
scripts/capture/master_transfer.pyscripts/visualization/render_scope_video.pypower-regulator-12v-to-9v/schematic/schematic.pyHow to Test
uv run pytestuv run ruff check .