Skip to content

Commit

Permalink
offline opt: log file names include batch specs
Browse files Browse the repository at this point in the history
  • Loading branch information
wingechr committed Jun 19, 2024
1 parent 8f2b3a6 commit 60c096e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions offline_optimization_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def main(
out_dir = Path(out_dir) if out_dir else cache_dir
out_dir.mkdir(exist_ok=True)

api = PtxboaAPI(data_dir=DEFAULT_DATA_DIR, cache_dir=cache_dir)

param_sets = generate_param_sets(api)

# filter for batch
index_from = index_from or 0
index_to = index_to or len(param_sets)
param_sets = param_sets[index_from:index_to]

# set up logging
fmt = "[%(asctime)s %(levelname)7s] %(message)s"
datefmt = "%Y-%m-%d %H:%M:%S"
Expand All @@ -117,18 +126,12 @@ def main(
format=fmt,
datefmt=datefmt,
handlers=[
logging.FileHandler(cache_dir / "offline_optimization_script.log"),
logging.FileHandler(
cache_dir / f"offline_optimization_script.{index_from}-{index_to}.log"
),
],
)
logging.info(f"starting offline optimization script with cache_dir: {cache_dir}")
api = PtxboaAPI(data_dir=DEFAULT_DATA_DIR, cache_dir=cache_dir)

param_sets = generate_param_sets(api)

# filter for batch
index_from = index_from or 0
index_to = index_to or len(param_sets)
param_sets = param_sets[index_from:index_to]

results = [] # save results
for params in progress.bar.Bar(
Expand Down Expand Up @@ -156,7 +159,9 @@ def main(

# save result
with open(
out_dir / "offline_optimization.results.json", "w", encoding="utf-8"
out_dir / f"offline_optimization.results.{index_from}-{index_to}.json",
"w",
encoding="utf-8",
) as file:
json.dump(
results,
Expand Down

0 comments on commit 60c096e

Please sign in to comment.