Skip to content

enum schemas and binding to C #526

Open
riccardosavorgnan wants to merge 3 commits into
3.0from
ricky/implement_hydra_v3
Open

enum schemas and binding to C #526
riccardosavorgnan wants to merge 3 commits into
3.0from
ricky/implement_hydra_v3

Conversation

@riccardosavorgnan

@riccardosavorgnan riccardosavorgnan commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

This PR introduces the enum schemas and binding to C to make sure of two things:

  • we can validate the values of a config are in the expected range with an explicit mapping between text and integer
  • we can validate the mapping between Enums in python and C behavior align.

The first point in particular let us run a validation of the config directly on the login node rather than waiting for run-time errors (we can add this to this pr if needed).

Note: co-authored with claude.

collision/offroad/traffic_light_behavior take "ignore"/"stop"/"remove"
instead of raw ints; drive.py maps names to binding constants, the C ini
parser rejects anything else, and IGNORE_INFRACTION/STOP_AGENT/REMOVE_AGENT
are exported to Python.
OmegaConf structured schema (config_schema.py) validates types, enum names,
and unknown keys at load_config time; test_config_schema.py asserts the
schema enum ints never drift from the drive.h constants exported by the
binding.
@riccardosavorgnan riccardosavorgnan marked this pull request as ready for review July 13, 2026 18:42
Comment thread pufferlib/ocean/drive/drive.h Outdated
Comment on lines 401 to 404
int collision_behavior; // IGNORE_INFRACTION, STOP_AGENT, or REMOVE_AGENT
int offroad_behavior; // IGNORE_INFRACTION, STOP_AGENT, or REMOVE_AGENT
int traffic_light_behavior; // IGNORE_INFRACTION, STOP_AGENT, or REMOVE_AGENT
int use_map_cache; // 0 = each env owns its map copy, 1 = share static geometry across envs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These names don't seem consistent with the other documentation?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems risky to me to have multiple variants of a naming scheme floating around

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. this is the minimal change of keeping the names we already had in the C part of the code. We could totally move everything to have the same names across python and C, and even enforce name matching with a test?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just feel like we might as well make that change here if we're going to do this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good! I'll look around and ask claude as well if there's any known/good pattern to follow here, otherwise we can just go with the intuition of naming everything the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants