Skip to content

Commit

Permalink
solve_network: add customisable logging frequency (#1521)
Browse files Browse the repository at this point in the history
Co-authored-by: Fabian Hofmann <[email protected]>
Co-authored-by: Fabian Neumann <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent a12d724 commit 2062f1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ solving:
rtol: 0.01

mem_mb: 30000 #memory in MB; 20 GB enough for 50+B+I+H2; 100 GB for 181+B+I+H2
memory_logging_frequency: 30 # in seconds
runtime: 6h #runtime in humanfriendly style https://humanfriendly.readthedocs.io/en/latest/


Expand Down
1 change: 1 addition & 0 deletions doc/configtables/solving.csv
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ solver,,,
-- options,--,Key listed under ``solver_options``.,Link to specific parameter settings.
solver_options,,dict,Dictionaries with solver-specific parameter settings.
mem,MB,int,Estimated maximum memory requirement for solving networks.
mem_logging_frequency,s,int,Interval in seconds at which memory usage is logged.
5 changes: 4 additions & 1 deletion scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,11 @@ def solve_network(n, config, params, solving, **kwargs):
co2_sequestration_potential=snakemake.params["co2_sequestration_potential"],
)

logging_frequency = snakemake.config.get("solving", {}).get(
"mem_logging_frequency", 30
)
with memory_logger(
filename=getattr(snakemake.log, "memory", None), interval=30.0
filename=getattr(snakemake.log, "memory", None), interval=logging_frequency
) as mem:
n = solve_network(
n,
Expand Down

0 comments on commit 2062f1e

Please sign in to comment.