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

InferredView fixes and enhancements #3851

Merged
merged 1 commit into from
Dec 7, 2023
Merged

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented Nov 29, 2023

What changes are proposed in this pull request?

Fix exceptions for unknown value type and ensure defaults are propagated correctly

How is this patch tested? If it is not, please explain why.

Using an operator with InferredView rendering a deeply nested object

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

@imanjra imanjra requested a review from a team November 29, 2023 18:46
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (1a9f431) 15.53% compared to head (b59597d) 15.57%.
Report is 8 commits behind head on develop.

❗ Current head b59597d differs from pull request most recent head 9b8fa04. Consider uploading reports for the commit 9b8fa04 to get more accurate results

Files Patch % Lines
...core/src/plugins/SchemaIO/utils/generate-schema.ts 0.00% 15 Missing ⚠️
...e/src/plugins/SchemaIO/components/InferredView.tsx 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3851      +/-   ##
===========================================
+ Coverage    15.53%   15.57%   +0.03%     
===========================================
  Files          731      729       -2     
  Lines        81497    81005     -492     
  Branches      1087     1075      -12     
===========================================
- Hits         12664    12615      -49     
+ Misses       68833    68390     -443     
Flag Coverage Δ
app 15.57% <0.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

},
};
} else if (isPrimitiveType(dominantType) && readOnly) {
} else if (isPrimitiveType(dominantType || "") && readOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably the crux of the fix, but I find it very hard to follow. Its odd that getDominantType() returns null(ish) values? A variable name or comment indicating that the || is due to it being an empty array (isn't that the only case where this happens?

Also I realize we're using existing utils here, but I'd rather have metadata be in object form than functions, the data is already there so its a bit odd to call functions to get at it:

const value = "foo";
const typeInfo = getTypeInfoForValue(value);
// typeInfo.isArray => false
// typeInfo.dominantType => null (rename to typeInfo.arrayItemDominantType)
// typeInfo.isPrimitive => true
// typeInfo.value => "foo"
// typeInfo.isNullish => false
// typeInfo.type => string
// etc

Both of these a minor comments, but thought they might be useful feedback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yah, that's right. dominantType will be unknown for an empty array. Planning to use something like one of view in future for unknown type but it can potentially be a nested object.

Not too sure about the second half of the comment. The generate-schema (I should probably rename to inferSchemaUsingValue(value) is only used for InferredView to generate a SchemaIO compatible schema based only on a value.

Copy link
Contributor

@ritch ritch left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from release/v0.23.0 to main December 5, 2023 23:13
@imanjra imanjra changed the base branch from main to develop December 6, 2023 16:42
@imanjra imanjra merged commit 6790f0e into develop Dec 7, 2023
15 checks passed
@imanjra imanjra deleted the bugfix/inferred-view branch December 7, 2023 19:19
@benjaminpkane benjaminpkane mentioned this pull request Jan 5, 2024
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