feat: adds option to cap core count for real spectrum run
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
This commit is contained in:
@@ -88,6 +88,7 @@ class RealSpectrumRun:
|
|||||||
chunksize: int = CHUNKSIZE,
|
chunksize: int = CHUNKSIZE,
|
||||||
initial_seed: int = 12345,
|
initial_seed: int = 12345,
|
||||||
use_fast_filter: bool = True,
|
use_fast_filter: bool = True,
|
||||||
|
cap_core_count: int = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.measurements = measurements
|
self.measurements = measurements
|
||||||
self.dot_inputs = [(measure.r, measure.f) for measure in self.measurements]
|
self.dot_inputs = [(measure.r, measure.f) for measure in self.measurements]
|
||||||
@@ -123,6 +124,8 @@ class RealSpectrumRun:
|
|||||||
self.filename = f"{timestamp}-{filename_slug}.realdata.{ff_string}.bayesrun.csv"
|
self.filename = f"{timestamp}-{filename_slug}.realdata.{ff_string}.bayesrun.csv"
|
||||||
self.initial_seed = initial_seed
|
self.initial_seed = initial_seed
|
||||||
|
|
||||||
|
self.cap_core_count = cap_core_count
|
||||||
|
|
||||||
def go(self) -> None:
|
def go(self) -> None:
|
||||||
with open(self.filename, "a", newline="") as outfile:
|
with open(self.filename, "a", newline="") as outfile:
|
||||||
writer = csv.DictWriter(outfile, fieldnames=self.csv_fields, dialect="unix")
|
writer = csv.DictWriter(outfile, fieldnames=self.csv_fields, dialect="unix")
|
||||||
@@ -145,6 +148,8 @@ class RealSpectrumRun:
|
|||||||
):
|
):
|
||||||
_logger.debug(f"Doing model #{model_count}: {model_name}")
|
_logger.debug(f"Doing model #{model_count}: {model_name}")
|
||||||
core_count = multiprocessing.cpu_count() - 1 or 1
|
core_count = multiprocessing.cpu_count() - 1 or 1
|
||||||
|
if (self.cap_core_count >= 1) and (self.cap_core_count < core_count):
|
||||||
|
core_count = self.cap_core_count
|
||||||
with multiprocessing.Pool(core_count) as pool:
|
with multiprocessing.Pool(core_count) as pool:
|
||||||
cycle_count = 0
|
cycle_count = 0
|
||||||
cycle_success = 0
|
cycle_success = 0
|
||||||
|
Reference in New Issue
Block a user