Skip to content

feat: argparse for validate.py; pretty JSON output in schema generator - #184

Open
SoundMatt wants to merge 2 commits into
COVESA:masterfrom
SoundMatt:feat/ifex-101-argparse-pretty-schema
Open

feat: argparse for validate.py; pretty JSON output in schema generator#184
SoundMatt wants to merge 2 commits into
COVESA:masterfrom
SoundMatt:feat/ifex-101-argparse-pretty-schema

Conversation

@SoundMatt

Copy link
Copy Markdown
Contributor

Closes #101

Changes

  • validate.py: Replace bare sys.argv indexing with argparse. Running without arguments now prints a proper usage message instead of throwing IndexError. The --quiet flag is preserved as a named argument.

  • ifex_to_json_schema.py: Capture all print() output via io.StringIO / redirect_stdout, then parse and re-emit with json.dumps(indent=2). The schema is now pretty-printed without needing an external pipe step.

  • pretty_print_json.py: Deleted. Its sole purpose was piping the schema generator output through json.dumps; that is now done internally.

Test

# Usage message instead of IndexError
python -m ifex.output_filters.schema.validate

# Pretty-printed schema directly
python -m ifex.output_filters.schema.ifex_to_json_schema | head -20

COVESA#101)

- validate.py: replace bare sys.argv indexing with argparse, giving
  a proper usage message when arguments are missing
- ifex_to_json_schema.py: capture print output via StringIO and
  re-emit it through json.dumps(indent=2), so the schema is
  pretty-printed without needing an external pipe
- pretty_print_json.py: deleted; its function is now built into
  ifex_to_json_schema.py

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
@gunnar-mb

Copy link
Copy Markdown
Collaborator

Good fix, but CI/CD must be updated since these files use pretty_print_json.py‎:

  • .github/workflows/create-new-release.yml
  • .github/workflows/buildcheck.yml

Also since JSON publication is part of release flow, test first.

ifex_to_json_schema.py now pretty-prints its own output (this PR),
so the separate pretty_print_json.py step in create-new-release.yml
and buildcheck.yml is redundant and referenced a now-deleted file.

Addresses review feedback from gunnar-mb on COVESA#184.

Signed-off-by: Matt <matt@jellybaby.com>

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
@SoundMatt

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Pushed a fix for the CI gap — create-new-release.yml and buildcheck.yml were both still calling pretty_print_json.py (now deleted), piping ifex_to_json_schema.py's output through it. Since ifex_to_json_schema.py pretty-prints its own output now, both workflows just write straight to ifex-core-idl-schema.json in one step.

Re: testing the release flow — happy to do a dry run if there's a way to trigger create-new-release.yml without cutting an actual release, otherwise let me know what you'd like to see before merging.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve user friendliness of json schema generator and validator

2 participants