add memory logger
This commit is contained in:
parent
be23b5c56a
commit
73df378837
@ -35,6 +35,8 @@ import pypsa
|
|||||||
import xarray as xr
|
import xarray as xr
|
||||||
from _helpers import configure_logging, update_config_with_sector_opts
|
from _helpers import configure_logging, update_config_with_sector_opts
|
||||||
|
|
||||||
|
from vresutils.benchmark import memory_logger
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
pypsa.pf.logger.setLevel(logging.WARNING)
|
pypsa.pf.logger.setLevel(logging.WARNING)
|
||||||
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
||||||
@ -718,13 +720,20 @@ if __name__ == "__main__":
|
|||||||
co2_sequestration_potential=snakemake.params["co2_sequestration_potential"],
|
co2_sequestration_potential=snakemake.params["co2_sequestration_potential"],
|
||||||
)
|
)
|
||||||
|
|
||||||
n = solve_network(
|
with memory_logger(filename=getattr(snakemake.log, 'memory', None), interval=30.) as mem:
|
||||||
n,
|
|
||||||
config=snakemake.config,
|
n = solve_network(
|
||||||
solving=snakemake.params.solving,
|
n,
|
||||||
opts=opts,
|
config=snakemake.config,
|
||||||
log_fn=snakemake.log.solver,
|
solving=snakemake.params.solving,
|
||||||
)
|
opts=opts,
|
||||||
|
log_fn=snakemake.log.solver,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info("Maximum memory usage: {}".format(mem.mem_usage))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
|
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
|
||||||
n.export_to_netcdf(snakemake.output[0])
|
n.export_to_netcdf(snakemake.output[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user