Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Add tf and sklearn version info to policy metadata #1528

Merged
merged 5 commits into from Jan 2, 2019
Merged

Conversation

ricwo
Copy link
Contributor

@ricwo ricwo commented Jan 2, 2019

Proposed changes:

  • fixes #1463

Status (please check what you already did):

  • made PR ready for code review
  • added some tests for the functionality
  • updated the documentation
  • updated the changelog

@ricwo ricwo requested a review from tmbo January 2, 2019 13:06
Copy link
Member

@tmbo tmbo left a comment

Choose a reason for hiding this comment

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

Looks good, some suggestions on how to generalize the code

@@ -97,12 +99,22 @@ def _create_action_fingerprints(training_events):
action_fingerprints[k] = {"slots": slots}
return action_fingerprints

def _add_module_version_info(self, metadata: Dict[Text, Any]) -> None:
"""Adds tensorflow and sklearn version info to metadata."""
if any(isinstance(p, KerasPolicy) for p in self.policies):
Copy link
Member

Choose a reason for hiding this comment

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

I think instead of checking for the policy name, we could also just try to import, e.g.

try:
    import tensorflow as tf
    metadata["tensorflow"] = tf.__version__
except ImportError:
    pass

We could even make this more general, create a class variable versioned_packages = ["tensorflow", "sklearn", "rasa_core"] and then iterate over that:

import importlib
for package_name in self.versioned_packages:
    p = importlib.import_module(package_name)
    metadata[package_name] = p.__version__

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't we only want the version info in the metadata if it was actually used during training?

Copy link
Member

Choose a reason for hiding this comment

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

This is a good point, this depends where the check for compatibility will be implemented. But I guess that is going to be in the policy used, so there shouldn't be an issue with persisting the verison even if tf is not used.

The reason why I don't want to use the KerasPolicy class check is, that e.g. the EmbeddingPolicy is using TF as well and is not inheriting from KerasPolicy so we would not persist the version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 In that case it's ready for another review

Copy link
Member

@tmbo tmbo left a comment

Choose a reason for hiding this comment

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

looks good

rasa_core/policies/ensemble.py Show resolved Hide resolved
@ricwo ricwo merged commit 7853d2c into master Jan 2, 2019
@tmbo tmbo deleted the extended_metadata branch March 8, 2019 12:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants