-
Notifications
You must be signed in to change notification settings - Fork 24
1104 dataservice and datareader for arbitrary json files #1304
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
Merged
gerrycampion
merged 31 commits into
main
from
1104-dataservice-and-datareader-for-arbitrary-json-files
Oct 13, 2025
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
5639642
Applying jsonata
gerrycampion 8ffd326
Merge remote-tracking branch 'origin/main' into 1104-dataservice-and-…
gerrycampion edd1255
Need the builder
gerrycampion 7a401b4
reporting works
gerrycampion 3eef17c
jsonata can now be direct value of the Check property
gerrycampion a52cf9f
Ability to load custom functions
gerrycampion 3d1439f
fix unit test missing arg
gerrycampion ed8da7a
Fix unit test missing arg
gerrycampion 667b125
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion 20fbfe1
jsonata unit test
gerrycampion cb81c6d
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion fe20f97
Added docs and fixed report message
gerrycampion 0f5dcc7
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion fddb998
process rule once for jsonata
gerrycampion 5a06310
Update result property names
gerrycampion 84ee8fa
fixed json for utf8, added error handling
gerrycampion b89c812
error handling for jsonata loading
gerrycampion dacf981
Schema fix
gerrycampion c5a2de9
Added builtin jsonata functions, cli multi function paths, better err…
gerrycampion 01c3d84
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion 3ed3311
removed unneeded jsonata files. fixed md indentation
gerrycampion 3de61a4
jsonata ignore scope
gerrycampion 69bb7a2
tweak output variables mapping
gerrycampion d755646
jsonata scope readme update
gerrycampion b59660b
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion d1d0160
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion 17295c5
Add _path preprocessing
gerrycampion 2413bd1
Merge branch 'main' into 1104-dataservice-and-datareader-for-arbitrar…
gerrycampion 07fa834
format fix
gerrycampion 6ab5015
fix merge bug
gerrycampion 770f8fa
missing test new args
gerrycampion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
cdisc_rules_engine/dataset_builders/jsonata_dataset_builder.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from json import load | ||
| from cdisc_rules_engine.dataset_builders.base_dataset_builder import BaseDatasetBuilder | ||
|
|
||
|
|
||
| def add_json_pointer_paths(node, path=""): | ||
| """ | ||
| Recursively adds a '_path' attribute to each dict node in the JSON structure, | ||
| using JSON Pointer syntax. | ||
| """ | ||
| if isinstance(node, dict): | ||
| node["_path"] = path | ||
| for key, value in node.items(): | ||
| if key != "_path": | ||
| add_json_pointer_paths(value, f"{path}/{key}") | ||
| elif isinstance(node, list): | ||
| for idx, item in enumerate(node): | ||
| add_json_pointer_paths(item, f"{path}/{idx}") | ||
|
|
||
|
|
||
| class JSONataDatasetBuilder(BaseDatasetBuilder): | ||
|
|
||
| def get_dataset(self, **kwargs): | ||
| if hasattr(self.data_service, "dataset_path"): | ||
| dataset_path = self.data_service.dataset_path | ||
| elif ( | ||
| hasattr(self.data_service, "dataset_paths") | ||
| and len(self.data_service.dataset_paths) == 1 | ||
| ): | ||
| dataset_path = self.data_service.dataset_paths[0] | ||
| else: | ||
| return None | ||
| with self.data_service.read_data(dataset_path) as fp: | ||
| json = load(fp) | ||
| add_json_pointer_paths(json) | ||
| return json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| from json import load | ||
| from cdisc_rules_engine.exceptions.custom_exceptions import InvalidJSONFormat | ||
| from cdisc_rules_engine.interfaces import ( | ||
| DataReaderInterface, | ||
| ) | ||
|
|
||
|
|
||
| class JSONReader(DataReaderInterface): | ||
| def from_file(self, file_path): | ||
| try: | ||
| with open(file_path, "rb") as fp: | ||
| json = load(fp) | ||
| return json | ||
| except Exception as e: | ||
| raise InvalidJSONFormat( | ||
| f"\n Error reading JSON from: {file_path}" | ||
| f"\n {type(e).__name__}: {e}" | ||
| ) | ||
|
|
||
| def read(self, data): | ||
| pass |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.