-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Remove special cases from SegmenationMethod.from_dict #363
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
Conversation
b434238 to
3dfaa36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test cases look good. All I did was rename commit titles. I'll approve this for merging, feel free to comment on below if anything raises a concern:
-
There are many lines of code designed specifically to handle how
ref_materialbeing set, when what this field expresses can be made simpler. What the inheritance hierarchy means is clashing with whatref_materialmeans (and it is settable in certain cases). We could remove the subclassing and ABC entirely, with everything being specified in a SegmentationMethod, or we could make this feature non-settable (even in constructors), make it class level for all specializations ofSegmentationMethod. -
I'm not sure whether the
graceful handling of old JSON files that may contain the
ref_materialkeyword.is an approach we should take for all things going forward, as it adds a lot of debt if we add handling to old versions of data. I think the project is small enough right now that we can keep the debt low and remove the field from the existing (small number) of JSON files. I'll approve it for merging anyway as this is cautionary but not a problem.
3dfaa36 to
29dfb1c
Compare
pyproject.toml
Outdated
| filterwarnings = [ | ||
| "error", | ||
| "ignore:Unsupported Windows version.*ONNX Runtime supports Windows 10 and above, only.:UserWarning", | ||
| "ignore:Ignoring unexpected keyword arguments for UniformWater.*:UserWarning", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really specific warning to be ignoring at the pyproject.toml level. If it's needed to get test_from_dict_on_keyword_mismatch to work properly, then I would say something is likely wrong with the test. Unless I misunderstood the purpose of it. It is a bit of a red flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... pytest runs fine without it. A few of these PRs have been trial runs of Jules, so good to know that it takes some ... unconventional approaches. Looks like I'd already achieved the desired behavior, but this snuck past me
I suppose we could remove |
I see the point here. I'm going to need to do a dvc update once the current set of changes come in, so maybe that's the point where I pull out this backwards-compatibility stuff |
|
Sounds good! You can re-request review from me when done with additional changes (we won't do any force-pushing till then -- the branch is in your hands, Peter. @arhowe00) |
|
Heads up that I'll force-push to fix merge conflicts and commit messages |
Removes the special-case handling for `UniformWater` and `UniformTissue` in `SegmentationMethod.from_dict`. Each subclass now overrides `to_dict` to exclude the `ref_material` attribute, which is implicit in the class and not a constructor argument. `SegmentationMethod.from_dict` now checks for unexpected keywords and handles them based on the `on_keyword_mismatch` parameter. This allows for graceful handling of old JSON files that may contain the `ref_material` keyword.
c2f30ea to
50558af
Compare
Removes the special-case handling for
UniformWaterandUniformTissueinSegmentationMethod.from_dict. Each subclass now overridesto_dictto exclude theref_materialattribute, which is implicit in the class and not a constructor argument.SegmentationMethod.from_dictnow checks for unexpected keywords and handles them based on theon_keyword_mismatchparameter. This allows for graceful handling of old JSON files that may contain theref_materialkeyword.Closes #362