feat(logging): add proper logging - #55
Draft
Arseni10Lk wants to merge 33 commits into
Draft
Arseni10Lk wants to merge 33 commits into
Arseni10Lk wants to merge 33 commits into
Conversation
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
…ained Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
Signed-off-by: Arseni10Lk <arseniy230606@gmail.com>
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.
Resolves #19
Prior to this PR, solver analyses across
YAADO_Corelacked a unified logging and output framework. Solvers relied on ad-hocprint()statements and frequently wrote temporary files (JSON results, CSV sweeps, and PNG plots) directly into module source directories (__file__.parent) or the repository root.This PR introduces the
FlightLoggersubsystem and standardizes simulation persistence across YAADO. It ensures:YAADO_Core/) never writes outputs inside its own source tree. All run artifacts are segregated into timestamped directories underFlightLogs/{vehicle}/{analysis}_{timestamp}/.units: dict[str, str]) onAnalysisResults.summary.csv) alongside machine-readable simulation checkpoints (results.json) and auxiliary files (artifacts/).enabled=False, all disk I/O, file logging, and plot rendering are skipped to avoid performance penalties in high-speed OpenMDAO evaluation loops.Key Architectural Changes
A. Centralized Run Directory Structure
Each analysis run produces a dedicated, self-contained directory under
FlightLogs/:B.
FlightLoggerCore (YAADO_Core/Foundation/flight_logger.py)info(),warning(),error(),debug(),exception()logging toexecution.log(with timestamped formatting) and optional console output. Handlers are safely cleaned up and detached inclose()to prevent file descriptor leaks.YaadoJSONEncoder): Custom encoder supporting NumPy scalars (.item()), multi-element NumPy arrays (.tolist()), Enums, Pydantic models,Pathobjects, and datetimes.save_figure):figures/.self.show_figures and show: enabling figure display shows only priority figures tagged withshow=True.close=True) to prevent memory leaks.save_results&load_results):save_resultsenforcesresults: AnalysisResults(rejecting unvalidated types withTypeError).results.json.load_resultsreconstructsAnalysisResultsand validatesfidelityagainstFidelityLevel, failing loudly withValueErroron corrupted or missing fidelity rather than silently masking errors.summary.csv):metric,value,unitfor primary scalar physics outputs. Placing this at Row 1 allows immediate auto-filtering, sorting, and graphing in Excel / LibreOffice Calc.metadata,value,unittable records checkpoint context (vehicle,analysis,timestamp,fidelity,iterations,converged,solver).results.json) to keep the spreadsheet lightweight and rectangular.save_artifact):str) or binary data (bytes) intoartifacts/(e.g. parametric sweeps, dense flight trajectories, mesh files, solver configuration scripts).C. First-Class Units in
AnalysisResults(YAADO_Core/Foundation/analysis_base.py)units: dict[str, str] = field(default_factory=dict)attribute.get_unit(key) -> str: Returns the declared physical unit (e.g.,"N","m/s","Pa"), defaulting cleanly to"-"when unannotated or dimensionless.to_dict() -> dict[str, Any]for uniform serialization.rpartition("_")), establishing a deterministic first-class metadata contract across the framework.Verification & Testing
Test Coverage Summary:
test_flight_logger.py):test_first_class_units_in_analysis_results: Verifies explicit units and clean default fallback ("-") without guessing.test_flight_logger_directories_created: Confirms automatic directory creation (figures/,artifacts/,execution.log).test_diagnostic_logging: Verifies log format, log level filtering, and handler detachment.test_console_logging: Verifies optional console StreamHandler output.test_save_figure_basic_and_headless: Tests saving PNGs, closing figures, and headless environment handling.test_save_and_load_results_checkpoint: Validates end-to-end JSON roundtrip, 2-tablesummary.csvgeneration, and metadata extraction.test_yaado_json_encoder_numpy: Confirms safe serialization of NumPy scalars, arrays, Paths, Enums, and datetimes.test_save_artifact: Tests string and binary writing intoartifacts/.test_disabled_logger_zero_overhead: Confirms zero disk I/O whenenabled=False.test_save_results_rejects_dict_or_invalid_type: Asserts strictAnalysisResultstype enforcement.test_load_results_rejects_missing_or_invalid_fidelity: Asserts loudValueErroron missing or corrupted fidelity integers.PR Checklist Compliance and Remaining tasks
uv run pytest tests/ --tb=short— all tests pass.YAADO_Core/Foundation/README.md.