Skip to content

Example of updating schema in TFX #144

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

Closed
albertnanda opened this issue Oct 31, 2020 · 3 comments
Closed

Example of updating schema in TFX #144

albertnanda opened this issue Oct 31, 2020 · 3 comments

Comments

@albertnanda
Copy link

I have created a schema using SchemaGen. I want to update one of the fields from required to optional. How can I do that?
https://www.tensorflow.org/tfx/tutorials/tfx/components_keras in this tutorial, every field is required. How can I make one of the fields optional.

Another question is how do I access the "domain" information from context.show(schema_gen.outputs['schema'])
programmatically.

@Mikehem
Copy link

Mikehem commented Nov 3, 2020

  1. Changing schema feature from optional to required and vice versa

first get the feature from the schema

feature = tfdv.get_feature(schema, feature_name) # this will be the column

for changing from required to optional add a value between 0.0 to 1.0

feature.presence.min_fraction = 0.9

for changing from optional to required

feature.presence.min_fraction = 1.0

display the schema to check if the changes have occured as desired

tfdv.display_schema(schema)

  1. Getting the domain values from SchemaGen

This may be a workaround for now. When you run the context, you will get a URI for the run metadata. You can also get it by running this -> schema_gen.outputs['schema'].to_json_dict()['artifacts'][0]['artifact']['uri'] + '/schema.pbtxt'

schema_uri = ''path to tfx pipeline/tfx/pipeline/SchemaGen/schema/19/schema.pbtxt'
schema_1 = tfdv.load_schema_text(schema_uri)
tfdv.get_domain(schema_1, "company")

@rmothukuru
Copy link

@albertnanda,
Can you please let us know if @Mikehem's comment worked for you. Thanks!

@albertnanda
Copy link
Author

It works, closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants