Add expression interpreter#71
Draft
ubdbra001 wants to merge 13 commits intobids-standard:mainfrom
Draft
Conversation
4229095 to
19cdfd0
Compare
19cdfd0 to
5bda559
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #71 +/- ##
===========================================
- Coverage 90.89% 80.38% -10.52%
===========================================
Files 13 14 +1
Lines 846 994 +148
Branches 124 175 +51
===========================================
+ Hits 769 799 +30
- Misses 47 165 +118
Partials 30 30 🚀 New features to boost your workflow:
|
=== Do not change lines below ===
{
"chain": [],
"cmd": "uv lock",
"exit": 0,
"extra_inputs": [],
"inputs": [
"pyproject.toml",
"uv.lock"
],
"outputs": [
"uv.lock"
],
"pwd": "."
}
^^^ Do not change lines above ^^^
=== Do not change lines below ===
{
"chain": [],
"cmd": "uv lock",
"exit": 0,
"extra_inputs": [],
"inputs": [
"pyproject.toml",
"uv.lock"
],
"outputs": [
"uv.lock"
],
"pwd": "."
}
^^^ Do not change lines above ^^^
Contributor
|
From today's call, here's a quick-and-dirty proxy to allow you to provide multiple namespaces and treat them as one: class LookupProxy:
def __init__(self, *objs):
self.objs = objs
def __getitem__(self, key):
for obj in self.objs:
if isinstance(obj, dict) and key in obj:
return obj[key]
if hasattr(obj, key):
return getattr(obj, key)
raise AttributeError
# Provide either attr or item lookup
__getattr__ = __getitem__Example usage: import bids_validator as bv
import bids_validator.context
from bids_validator import expression_language as el
from bids_validator.types.files import FileTree
from bidsschematools.schema import load_schema
schema = load_schema()
root = FileTree.read_from_filesystem('tests/data/bids-examples/ds000117/')
ds = bv.context.Dataset(root, schema)
file = root / 'sub-01' / 'ses-mri' / 'anat' / 'sub-01_ses-mri_acq-mprage_T1w.nii.gz'
context = bv.context.Context(file, ds, None)
namespace = LookupProxy(el.ids, context) |
Primary change is in Element case to handle nulls, changes in Function case are more for my understanding
Collaborator
Author
|
The |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Here's the initial attempt at adding all the parts of the expression language interpreter.
These successfully cover the full range of tests in the
bidsschematoolsexpression tests.Two things that still need addressing:
existspasses the tests but needs more work to actually work as described in the schema tools docsContext