|
19 | 19 |
|
20 | 20 | from activitysim.core import config, mem, tracing, util, workflow |
21 | 21 | from activitysim.core.configuration import FileSystem, Settings |
| 22 | +from activitysim.core.exceptions import * |
22 | 23 | from activitysim.core.run_id import RunId |
23 | 24 | from activitysim.core.workflow.checkpoint import ( |
24 | 25 | CHECKPOINT_NAME, |
|
27 | 28 | NON_TABLE_COLUMNS, |
28 | 29 | ParquetStore, |
29 | 30 | ) |
30 | | -from activitysim.core.exceptions import * |
31 | 31 |
|
32 | 32 | logger = logging.getLogger(__name__) |
33 | 33 |
|
@@ -257,6 +257,21 @@ def exception(state: workflow.State, msg, write_to_log_file=True): |
257 | 257 | logger.log(logging.ERROR, f"\n---\n{traceback.format_exc()}---\n") |
258 | 258 |
|
259 | 259 |
|
| 260 | +def log_environment_info(state: workflow.State): |
| 261 | + """log environment info for debugging purposes.""" |
| 262 | + if os.environ.get("ASIM_LOG_ENVIRON", False): |
| 263 | + process_name = multiprocessing.current_process().name |
| 264 | + environ_summary = f"OS.ENVIRON in process {process_name}:" |
| 265 | + for k, v in os.environ.items(): |
| 266 | + environ_summary += f"\n--- {k}: {v}" |
| 267 | + info(state, environ_summary) |
| 268 | + else: |
| 269 | + info( |
| 270 | + state, |
| 271 | + "ASIM_LOG_ENVIRON not set, skipping logging of environment variables. Set ASIM_LOG_ENVIRON=1 to log environment variables.", |
| 272 | + ) |
| 273 | + |
| 274 | + |
260 | 275 | """ |
261 | 276 | ### child process methods (called within sub process) |
262 | 277 | """ |
@@ -1097,6 +1112,7 @@ def mp_run_simulation( |
1097 | 1112 | state, |
1098 | 1113 | f"mp_run_simulation {step_info['name']} locutor={state.get_injectable('locutor', False)} ", |
1099 | 1114 | ) |
| 1115 | + log_environment_info(state) |
1100 | 1116 |
|
1101 | 1117 | try: |
1102 | 1118 | if step_info["num_processes"] > 1: |
@@ -1417,6 +1433,7 @@ def check_proc_status(state: workflow.State): |
1417 | 1433 | completed = set(previously_completed) |
1418 | 1434 | failed = set([]) # so we can log process failure first time it happens |
1419 | 1435 | drop_breadcrumb(state, step_name, "completed", list(completed)) |
| 1436 | + log_environment_info(state) |
1420 | 1437 |
|
1421 | 1438 | for i, process_name in enumerate(process_names): |
1422 | 1439 | q = multiprocessing.Queue() |
|
0 commit comments