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

Warning "No property is defined for the Type" when creating a ContextType #131

Closed
svpino opened this issue Oct 30, 2021 · 2 comments
Closed

Comments

@svpino
Copy link

svpino commented Oct 30, 2021

I'm using ml-metadata in one of my projects.

For some reason, any time I'm trying to create a new context type, I get the following message back:

WARNING: Logging before InitGoogleLogging() is written to STDERR
I1030 16:06:27.180933 245175808 rdbms_metadata_access_object.cc:686] No property is defined for the Type

Despite this, everything works fine. The problem is that the logs accumulate really quickly, especially when running the suite of tests.

Is there any way to avoid this warning?

Here is a snippet of code that reproduces the problem:

connection_config = ConnectionConfig()
connection_config.fake_database.SetInParent()
store = metadata_store.MetadataStore(connection_config)

context_type = ContextType()
context_type.name = "sample"
context_type_id = store.put_context_type(context_type)
@BrianSong
Copy link
Collaborator

Hi, @svpino . The warning is because you are creating a context_type without any properties and your context_type is not a simple type. See the detail root cause in [1]. This is the default behavior.

If you want to avoid this warning, one simple way is to create your own branch in ml_metadata, comment out line 685-686 and build the ml_metadata from source as instructed in [2]. In this way, your ml_metadata library will not raise these warnings.

Please let me know if you have any other questions.

[1] https://github.com/google/ml-metadata/blob/master/ml_metadata/metadata_store/rdbms_metadata_access_object.cc#L685
[2] https://github.com/google/ml-metadata#installing-from-source

@svpino
Copy link
Author

svpino commented Nov 2, 2021

Thanks for the reply, @BrianSong!

I simply ended up doing the following:

connection_config = ConnectionConfig()
connection_config.fake_database.SetInParent()
store = metadata_store.MetadataStore(connection_config)

context_type = ContextType()
context_type.name = "sample"

# Get rid of the warning by defining a property.
context_type.properties["sample"] = 1

context_type_id = store.put_context_type(context_type)

Honestly, I'm not quite sure about the implications of adding that property, but it gets rid of the warning. This is probably a good opportunity to improve the documentation of the library around this topic.

Thanks for the references!

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

No branches or pull requests

2 participants