-
Notifications
You must be signed in to change notification settings - Fork 0
Implement json style arguments for behaviors in generate-tables command #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if behavior_config: | ||
| try: | ||
| config = load_json(behavior_config) | ||
| if not isinstance(config, dict) or "behaviors" not in config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could use jsonschema.validate() to validate the json (I don't think this needs to change for this pull request).
| except json.JSONDecodeError as e: | ||
| raise ValueError(f"Invalid JSON in file {source}: {e}") | ||
|
|
||
| elif isinstance(source, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the isinstance(source, str) block could be simplified by checking Path(source).exists() first to see if it is a path, then fall back to parsing the string as JSON and if that fails finally check if it is one of the quoted strings?
I think this could avoid the multiple attempts to open it as a file
| ), | ||
| ] = True, | ||
| behavior_config: Path | None = typer.Option( | ||
| None, "--behavior-config", help="JSON file with behavior configurations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could benefit from indicating some structure of the JSON, e.g. what fields it expects and which are optional.
This change allows you to specify behavior params for the generate-table command using json!