Skip to content
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

ENH: Add --force option to script tools/update_schema #745

Merged

Conversation

slangeveld
Copy link
Contributor

@slangeveld slangeveld commented Jul 8, 2024

Resolving #740

Adds a new argument --force to the tools/update_schema script that is used to update fmu_meta.json schema.

This has been added to have a way to force an overwrite of the current json schema, if the current json schema has been malformed for some reason, e.g. because of a merge conflict.

Changes :

  1. --force has been added as a new valid argument to the script
  2. When running the script with the --force argument, the script will skip checking/validating the current schema and overwrite with the new one.
  3. In case of a json parsing error of the current json schema, the script will exit and inform the user about the possibility of running the script with the --force argument.

Local testing
The changes has been testes locally by:

  1. Editing the current schema fmu_meta.json to be an unvalid json, followed by running the script to see that the json parse error was outputted to the user, in addition to the suggestion of running the script with the --force argument.
  2. Running the script with the new argument --force to see if the schema was overridden.

@slangeveld slangeveld requested a review from mferrera July 8, 2024 13:44
Copy link
Collaborator

@mferrera mferrera left a comment

Choose a reason for hiding this comment

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

Nice 👍 I think the we should give a fail exit status when json parsing is fails but otherwise good to go

"to overwrite with the new schema.\n"
f"{FAILURE} Json parsing error: '{json_decode_error.msg}.'"
)
sys.exit()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
sys.exit()
sys.exit(1)

I think it'd be good to indicate an error status with the exit code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Will add that

@slangeveld slangeveld merged commit 17e68fa into equinor:main Jul 9, 2024
13 checks passed
@slangeveld slangeveld deleted the 740-add-force_option-to-update_schema branch July 9, 2024 07:09
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