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

Unified Schema #184

Merged
merged 15 commits into from Feb 18, 2022
Merged

Unified Schema #184

merged 15 commits into from Feb 18, 2022

Conversation

benfred
Copy link
Member

@benfred benfred commented Feb 15, 2022

This modifies merlin-models to be compatabile with the new 'core' schema class that
will be shared with NVTabular

This modifies merlin-models to be compatabile with the new 'core' schema class that
will be shared with NVTabular
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@benfred benfred marked this pull request as draft February 15, 2022 01:51
@benfred benfred marked this pull request as ready for review February 18, 2022 00:29
tests/tf/test_core.py Outdated Show resolved Hide resolved
@marcromeyn marcromeyn merged commit c7fad98 into main Feb 18, 2022
@marcromeyn marcromeyn deleted the unify_schema branch February 18, 2022 08:27
Copy link
Contributor

@karlhigley karlhigley left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. Left a few comments on things we might want to abstract further, and one spot where I think there's a method name typo that didn't get caught by the tests.

@@ -99,9 +104,9 @@ def read_schema(cls, path: Union[str, Path]) -> Schema:
os.path.join(str(path), "schema.json") if os.path.isdir(str(path)) else str(path)
)
if _schema_path.endswith(".pb") or _schema_path.endswith(".pbtxt"):
return Schema().from_proto_text(_schema_path)
TensorflowMetadata.from_from_proto_text(_schema_path).to_merlin_schema()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be from_proto_text_file? Also not sure this works with the way that method is written, since I think the current implementation wants the directory and assumes the file is called schema.pbtxt unless you pass a different value of the filename param. Now wondering if this is covered by tests too...

query_item_schema = schema.select_by_tag(
lambda tags: query_id_tag in tags or item_id_tag in tags
)
query_item_schema = schema.select_by_tag(query_id_tag) + schema.select_by_tag(item_id_tag)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a reasonable way to implement the same behavior on the other version of the Schema API. I do wonder if we should think about integrating the lambda functionality into core though.

if isinstance(item, Tags):
item = item.value
else:
item = str(item)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this could be a helper on Tags to keep the behavior encapsulated. Something like:

class Tags(Enum):
    ...
    @classmethod
    def value(cls, maybe_tag):
        if isinstance(maybe_tag, Tags):
            return item.value
        else:
            return str(item)

benfred added a commit that referenced this pull request Feb 18, 2022
As pointed out #184 (comment)
there was some issues with the SyntheticData.read_schema method. Fix
and add a basic unittest that would have caught this
marcromeyn pushed a commit that referenced this pull request Feb 22, 2022
As pointed out #184 (comment)
there was some issues with the SyntheticData.read_schema method. Fix
and add a basic unittest that would have caught this
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.

None yet

3 participants