grass icon indicating copy to clipboard operation
grass copied to clipboard

Add a standard parser option for JSON formatting

Open kritibirda opened this issue 1 year ago • 7 comments

As a part of https://github.com/OSGeo/grass/discussions/3019, JSON format support will be added to multiple modules. By default, modules output in existing plain format. If the format=json option is provided, modules will output in JSON format instead. To avoid duplication of code across several modules, define a standard parser option.

kritibirda avatar May 13 '24 06:05 kritibirda

This is great improvement @kritibirda26. To fix the OSGeo4W CI, please update your branch from main (e.g. Update branch on GitHub or merge main locally into this branch).

wenzeslaus avatar May 14 '24 20:05 wenzeslaus

@petrasovaa Hi! I have updated v.db.select and also changed the option to be required by default.

kritibirda avatar May 17 '24 08:05 kritibirda

The tests are failing with this weird error but the build passes locally. Also, the string that is said to be invalid is actually a valid isoformat string. Any suggestions on how to debug?

gnu/docs/html/g.gui.timeline.html
Traceback (most recent call last):
  File "/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/utils/mkhtml.py", line 921, in <module>
    git_commit = get_last_git_commit(
  File "/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/utils/mkhtml.py", line 397, in get_last_git_commit
    return parse_git_commit(
  File "/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/utils/mkhtml.py", line 242, in parse_git_commit
    git_log["date"] = format_git_commit_date_from_local_git(
  File "/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/utils/mkhtml.py", line 345, in format_git_commit_date_from_local_git
    return datetime.fromisoformat(
ValueError: Invalid isoformat string: '2024-05-17T16:09:45Z'

https://github.com/OSGeo/grass/actions/runs/9131120968/job/25109628154?pr=3704#step:8:6469

kritibirda avatar May 17 '24 17:05 kritibirda

A guess: it probably expects a string without the 'Z' character?

neteler avatar May 17 '24 17:05 neteler

@neteler I see, do you know if there is a local git setting I can configure to fix the datetime format for the commit timestamp?

kritibirda avatar May 17 '24 17:05 kritibirda

This is failing across several PRs with repeated runs. I'm opening a separate issue to discuss this.

wenzeslaus avatar May 18 '24 01:05 wenzeslaus

What prefix for the title of the PR should be used before merging, once it is rebased? (the build issue is most probably fixed now on main).

echoix avatar May 19 '24 17:05 echoix

Thanks all for reviewing the PR and helping fix the CI issues. Please let me know me if any other changes are needed in this PR.

kritibirda avatar May 24 '24 19:05 kritibirda

@petrasovaa previously requested changes, she might want to place an approval to overrule her review.

And a prefix for the PR, so it can be classified in the release notes. I'm not sure which one to apply.

echoix avatar May 24 '24 21:05 echoix

Sorry for beeing late here.

I just noticed that this new standard parser option:

  1. is not groupt with the other F options but comes last in the list (so out of order). See: https://grass.osgeo.org/grass84/manuals/parser_standard_options.html
  2. does not have a decription (seems to be a typo with descriptions)
  3. should probably explicitly default to NO for "multiple"

Should the format option also cover other formats (CSV, shell, ...), those are currently missing, but a long list of possible formats will probably defeat the purpose of the standard paser option?

Just comments you may consider... Anyway, I am glad to see this standard parser option...

ninsbl avatar May 29 '24 13:05 ninsbl