Utilities¶
Environment creation¶
create_eval_envs
¶
create_eval_envs(
num_threads: int,
num_envs_per_thread: int,
env_seed: int,
gym_id: str,
wrappers: list[Wrapper] | None = None,
vecenv_cls: type = AsyncVectorEnv,
**gym_kwargs: Any,
) -> list[Env]
Create vectorized evaluation environments in the format expected by Evaluator.
Builds num_threads vectorized environments, each bundling num_envs_per_thread copies of
gym_id. Each individual environment is seeded with a unique, incrementing seed derived from
env_seed, and wrapped with the given wrappers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_threads
|
int
|
Number of vectorized environments to create (one per evaluation thread). |
required |
num_envs_per_thread
|
int
|
Number of parallel environments within each vectorized environment. |
required |
env_seed
|
int
|
Base seed. Environment |
required |
gym_id
|
str
|
The Gymnasium environment ID passed to |
required |
wrappers
|
list[Wrapper] | None
|
Gymnasium wrappers applied to each environment; first = innermost. |
None
|
vecenv_cls
|
type
|
The vectorized-environment class to use (e.g. |
AsyncVectorEnv
|
**gym_kwargs
|
Any
|
Extra keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
list[Env]
|
A list of |
Source code in pydsmc/utils.py
Reading results¶
jsons_to_df
¶
jsons_to_df(
log_dir: Path | str | PathLike,
save_path: Path | str | PathLike | None = None,
*,
include_timeseries: bool = False,
first_converged_row: bool = False,
save: bool = True,
only_latest: bool = True,
) -> DataFrame
Aggregate the JSON-Lines logs of an evaluation run into a pandas DataFrame.
Reads the per-property results.jsonl files written under log_dir, merges them with the run
and property settings, and returns the combined results. Optionally also writes the aggregated
results to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
Path | str | PathLike
|
Directory containing an evaluation run's logs (the run's |
required |
save_path
|
Path | str | PathLike | None
|
Where to write the aggregated results. Defaults to |
None
|
include_timeseries
|
bool
|
Include every intermediate result (the full time series) rather than just the final row per property. |
False
|
first_converged_row
|
bool
|
Keep the first row where the interval converged (falling back to the
last available row if none converged). Ignored if |
False
|
save
|
bool
|
Whether to write the aggregated results to |
True
|
only_latest
|
bool
|
Only read the properties referenced in the run's |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A |