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

Adding schema validation for template configuration #60

Merged
merged 2 commits into from
Oct 5, 2022

Conversation

SpyzzVVarun
Copy link
Contributor

@SpyzzVVarun SpyzzVVarun commented Oct 3, 2022

Sorry for the unnecessary amount of commits you see.

The main changes are as follows:

  1. Added jsonschema requirement to requirements.txt
  2. Added code to template.py that updates imports, open_template_with_defaults function
  3. Added code to core.py that updates process_dir function
  4. Added schema.json
  5. Added code to file.py that updates imports, adds load_schema and validate_json functions
  6. Added a sampleError folder which contains a template.json file with some errors

P.S. I am very new to Open Source Contribution and am open to any and all feedback.

@Udayraj123 Udayraj123 self-requested a review October 3, 2022 18:22
@SpyzzVVarun SpyzzVVarun marked this pull request as ready for review October 3, 2022 18:23
@SpyzzVVarun SpyzzVVarun marked this pull request as draft October 4, 2022 03:26
src/defaults/schema.json Outdated Show resolved Hide resolved
src/defaults/schema.json Outdated Show resolved Hide resolved
src/core.py Outdated Show resolved Hide resolved
src/template.py Show resolved Hide resolved
samples/sampleError/template.json Outdated Show resolved Hide resolved
Copy link
Owner

@Udayraj123 Udayraj123 left a comment

Choose a reason for hiding this comment

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

resolve above comments

@Udayraj123 Udayraj123 marked this pull request as ready for review October 4, 2022 16:54
@Udayraj123
Copy link
Owner

Need a separate issue for enhancements in schema:

  1. All labels in all of the QBlocks should be covered in either Singles or concatenations.
  2. Also none of the labels in qBlocks should overlap (show warning in this case)
  3. User friendly messages: suggestion to convert key into camelCase (in which case validation error should mention that).

@SpyzzVVarun
Copy link
Contributor Author

Error Message for sampleError:

error_message

@Udayraj123
Copy link
Owner

use table for outputting errors:
example https://pythonfusion.com/table-on-console-python/

@SpyzzVVarun
Copy link
Contributor Author

use table for outputting errors: example https://pythonfusion.com/table-on-console-python/

Is this part of this PR only or included in the enhancement issue?

src/core.py Outdated Show resolved Hide resolved
src/defaults/schema.json Outdated Show resolved Hide resolved
src/defaults/schema.json Outdated Show resolved Hide resolved
src/defaults/schema.json Outdated Show resolved Hide resolved
src/template.py Outdated Show resolved Hide resolved
src/utils/file.py Outdated Show resolved Hide resolved

table = Table(show_lines = True)
table.add_column("Key", style="cyan", no_wrap=True)
table.add_column("Error", style="magenta")
Copy link
Owner

Choose a reason for hiding this comment

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

table can also come out. Make sure to reset it otherwise it's okay to keep inside.

src/utils/file.py Outdated Show resolved Hide resolved
src/utils/file.py Outdated Show resolved Hide resolved
src/utils/file.py Outdated Show resolved Hide resolved
src/defaults/schema.json Show resolved Hide resolved
from rich.console import Console
from rich.table import Table
import re
from ..constants import SCHEMA_DEFAULTS_PATH
Copy link
Owner

Choose a reason for hiding this comment

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

use absolute path, .. is a bit error-prone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Udayraj123
Copy link
Owner

Fixes #43

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.

None yet

2 participants