Refactoring, split into more files. Add more personalisation

This commit is contained in:
Noe Brucy
2020-02-04 11:34:09 +01:00
parent beb6203d06
commit a87abeb52d
8 changed files with 1234 additions and 959 deletions
+33
View File
@@ -0,0 +1,33 @@
from postprocessor import *
def _map_rule(rule, arg, overwrite, path, path_out, pp_params, run_num):
try:
pp = PostProcessor(
path + "/" + run_num[0], run_num[1], path_out + "/" + run_num[0], pp_params
)
except Exception as e:
print(e)
return pp.process(rule, arg, overwrite)
class Aggregator:
def _not_self_dep(self, name, dep, dep_arg, overwrite, **kwargs):
if "runs" in kwargs:
dep_runs = [run for run in self.runs if run in kwargs["runs"]]
else:
dep_runs = self.runs
run_num = [(run, num) for run in dep_runs for num in self.nums[run]]
map_fn = partial(
_map_rule, dep, dep_arg, overwrite, self.path, self.path_out, self.pp_params
)
if self.pp_params.process.num_process > 1:
pool = Pool(processes=self.pp_params.process.num_process)
done = pool.map(map_fn, run_num)
pool.close()
pool.join()
else:
done = map(map_fn, run_num)
self.just_done.extend([item for li in done for item in li])