Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created July 28, 2020 12:46
Show Gist options
  • Save ntakouris/5c877377f11d02d2b1b0eaf9f4f3876f to your computer and use it in GitHub Desktop.
Save ntakouris/5c877377f11d02d2b1b0eaf9f4f3876f to your computer and use it in GitHub Desktop.
metadata_connection_config = metadata.sqlite_metadata_connection_config(
os.path.join(bucket_uri, 'schema_generation', 'metadata.db')) # defaults to this
with metadata.Metadata(metadata_connection_config) as store:
schema_artifacts = store.get_artifacts_by_type(
standard_artifacts.Schema.TYPE_NAME)
latest_schema_uri = max(schema_artifacts, key=attrgetter(
'last_update_time_since_epoch')).uri
latest_schema_uri = os.path.join(latest_schema_uri, 'schema.pbtxt')
print(f'Schema at {latest_schema_uri}:')
with open(latest_schema_uri, 'r') as f:
print(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment