Feat/custom cmd - #216
Merged
HendriceH merged 11 commits intoAug 25, 2026
Merged
Conversation
Collaborator
|
Nice thank you! I'll have a look after the workshop. |
There was a problem hiding this comment.
Pull request overview
Adds optional parsing of OpenFOAM PIMPLE solver logs during obr postProcess, producing a pimple_logs.json artifact alongside postpro.json based on YAML configuration under pimpleParser.
Changes:
- Introduces
LogParserimplementation to extract PIMPLE iteration/residual/runtime metadata from solver logs. - Extends
obr postProcessto conditionally run the PIMPLE parser and writepimple_logs.json. - Adds YAML-config-driven parameters for parser behavior (e.g.,
write_interval,n_cells,lin_tol,t_skip).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/obr/pimple_log_parser.py | New PIMPLE log parser module that extracts runtime/residual/scheme metadata into a structured dict. |
| src/obr/cli.py | Integrates the new parser into postProcess and writes pimple_logs.json when configured. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+9
| from glob import glob | ||
| import os | ||
| import numpy as np | ||
| import re | ||
| import logging | ||
| import gzip | ||
| import json | ||
| import os | ||
| import threading |
Comment on lines
+824
to
+829
| try: | ||
| foundpath=glob.glob(self.log_file_path) | ||
| # Handle standard or compressed file | ||
| if foundpath[0].endswith("gz"): | ||
| isbinary=True | ||
| f = gzip.open(foundpath[0], "rb") |
Comment on lines
+281
to
+288
| t_skip_interval_from_log = self.get_time_from_log() | ||
| if t_skip_interval_from_log is not None: | ||
| logger.info(f"Detected time interval from log: {t_skip_interval_from_log}") | ||
| self.t_skip = t_skip_interval_from_log | ||
|
|
||
| if self.t_skip is None: | ||
| logger.fatal("Could not determine time interval from log. Please provide t_skip as an option to this script.") | ||
| return None |
Comment on lines
+368
to
+371
| nContiCalcs=0 | ||
| tmp_iters_p=0 | ||
| listen4write=False | ||
|
|
Comment on lines
+200
to
+218
| parsed = parse_fvschemes(self.log_as_bigstring) | ||
|
|
||
| entries = {} | ||
| for i in get_all_variables_global(simplify_keys(parsed)): | ||
| obj = { | ||
| "ddt_schemes": simplify_keys(parsed).get("ddtSchemes", {}).get(i) or simplify_keys(parsed).get("ddtSchemes", {}).get(f"phi,{i}") or simplify_keys(parsed).get("ddtSchemes", {}).get("default") or None, | ||
| "div_schemes": simplify_keys(parsed).get("divSchemes", {}).get(i) or simplify_keys(parsed).get("divSchemes", {}).get(f"phi,{i}") or simplify_keys(parsed).get("divSchemes", {}).get("default") or None, | ||
| "laplacian_schemes": simplify_keys(parsed).get("laplacianSchemes", {}).get(i) or simplify_keys(parsed).get("laplacianSchemes", {}).get("default") or None, | ||
| "sn_grad_schemes": simplify_keys(parsed).get("snGradSchemes", {}).get(i) or simplify_keys(parsed).get("snGradSchemes", {}).get(f"phi,{i}") or simplify_keys(parsed).get("snGradSchemes", {}).get("default") or None, | ||
| "interpolation_schemes": simplify_keys(parsed).get("interpolationSchemes", {}).get(i) or simplify_keys(parsed).get("interpolationSchemes", {}).get(f"phi,{i}") or simplify_keys(parsed).get("interpolationSchemes", {}).get("default") or None, | ||
| "thermophysical_properties": simplify_keys(parsed).get("thermophysical_properties", {}).get(i) or simplify_keys(parsed).get("thermophysical_properties", {}).get(f"phi,{i}") or simplify_keys(parsed).get("thermophysical_properties", {}).get("default") or None, | ||
| "turbulence_model_type": simplify_keys(parsed).get("turbulence_model_type", {}).get(i) or simplify_keys(parsed).get("turbulence_model_type", {}).get(f"phi,{i}") or simplify_keys(parsed).get("turbulence_model_type", {}).get("default") or None, | ||
| "turbulence_model_type_name": simplify_keys(parsed).get("turbulence_model_type_name", {}).get(i) or simplify_keys(parsed).get("turbulence_model_type_name", {}).get(f"phi,{i}") or simplify_keys(parsed).get("turbulence_model_type_name", {}).get("default") or None, | ||
| "turbulence_model_les_delta": simplify_keys(parsed).get("turbulence_model_les_delta", {}).get(i) or simplify_keys(parsed).get("turbulence_model_les_delta", {}).get(f"phi,{i}") or simplify_keys(parsed).get("turbulence_model_les_delta", {}).get("default") or None, | ||
| "turbulence_model_coefficients": simplify_keys(parsed).get("turbulence_model_coefficients", {}).get(i) or simplify_keys(parsed).get("turbulence_model_coefficients", {}).get(f"phi,{i}") or simplify_keys(parsed).get("turbulence_model_coefficients", {}).get("default") or None, | ||
| "thermophysical_properties_eos": simplify_keys(parsed).get("thermophysical_properties_eos", {}).get(i) or simplify_keys(parsed).get("thermophysical_properties_eos", {}).get(f"phi,{i}") or simplify_keys(parsed).get("thermophysical_properties_eos", {}).get("default") or None, | ||
| "thermophysical_properties_energy": simplify_keys(parsed).get("thermophysical_properties_energy", {}).get(i) or simplify_keys(parsed).get("thermophysical_properties_energy", {}).get(f"phi,{i}") or simplify_keys(parsed).get("thermophysical_properties_energy", {}).get("default") or None, | ||
| "thermophysical_properties_transport": simplify_keys(parsed).get("thermophysical_properties_transport", {}).get(i) or simplify_keys(parsed).get("thermophysical_properties_transport", {}).get(f"phi,{i}") or simplify_keys(parsed).get("thermophysical_properties_transport", {}).get("default") or None | ||
| } |
Comment on lines
+45
to
+49
| from .core.core import map_view_folder_to_job_id, profile_call | ||
| from .core.logger_setup import logger, setup_logging | ||
|
|
||
| from .core.core import map_view_folder_to_job_id | ||
| from .pimple_log_parser import LogParser |
Comment on lines
+617
to
+626
| if pimple_parser_config is not None and LogParser.is_pimple_log(log_path): | ||
| parser = LogParser( | ||
| log_file_path=log_path, | ||
| lin_tol=pimple_parser_config["lin_tol"], | ||
| n_cells= pimple_parser_config["n_cells"], | ||
| n_cells_search_dir=pimple_parser_config["n_cells_path"], | ||
| t_skip=pimple_parser_config["t_skip"], | ||
| write_interval=pimple_parser_config["write_interval"], | ||
| write_interval_search_dir=pimple_parser_config["write_interval_path"], | ||
| ) |
Comment on lines
+630
to
+633
| except Exception as E: | ||
| print(E) | ||
| raise E | ||
| logger.error(f"Unable to pimple-parse {log_path} !") |
Removed unused imports
SilasHelgesson
marked this pull request as draft
July 14, 2026 08:30
Author
|
We detected some issues with the parsing script, we will internally review then re-submit |
Collaborator
|
In general, I think it would be most useful to check if and how OBR can be used in combination with claude/gemini etc. |
Author
|
I added a new parser that handle Piso and Simple Foam logs as well ! |
SilasHelgesson
marked this pull request as ready for review
August 18, 2026 09:38
HendriceH
merged commit Aug 25, 2026
2034a5d
into
exasim-project:feat/custom_cmd
3 of 5 checks passed
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.
Within Upstream CFD sepcifically me and @HendriceH, we discussed the need to parse PIMPLE logs effectively within the OBR.
This script adds that capability. Configuration is done through the standard
.yamlfile for a study. For example:This will produce a file called:
pimple_logs.jsonwithin the same directory aspostpro.json.Configuration is optinal: If you do not have the need to parse pimple logs you may just leave it out.