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

Commit

Permalink
Merge pull request #1108 from RasaHQ/date-in-persist-metadata
Browse files Browse the repository at this point in the history
Add training date and time to policy metadata when persisting  Fixes #1104
  • Loading branch information
MetcalfeTom committed Oct 2, 2018
2 parents 9be1e14 + d100157 commit f22a888
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -15,6 +15,7 @@ Added
-----
- openapi documentation of server API
- added action prediction confidence & policy to ``ActionExecuted`` event
- both the date and the time at which a model was trained are now included in the policy's metadata when it is persisted

Changed
-------
Expand Down
6 changes: 5 additions & 1 deletion rasa_core/policies/ensemble.py
Expand Up @@ -8,6 +8,7 @@
import logging
import os
import sys
import datetime
from collections import defaultdict

import numpy as np
Expand Down Expand Up @@ -39,6 +40,7 @@ def __init__(self, policies, action_fingerprints=None):
# type: (List[Policy], Optional[Dict]) -> None
self.policies = policies
self.training_trackers = None
self.date_trained = None

if action_fingerprints:
self.action_fingerprints = action_fingerprints
Expand All @@ -65,6 +67,7 @@ def train(self, training_trackers, domain, **kwargs):
for policy in self.policies:
policy.train(training_trackers, domain, **kwargs)
self.training_trackers = training_trackers
self.date_trained = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
else:
logger.info("Skipped training, because there are no "
"training samples.")
Expand Down Expand Up @@ -123,7 +126,8 @@ def _persist_metadata(self, path, dump_flattened_stories=False):
"python": ".".join([str(s) for s in sys.version_info[:3]]),
"max_histories": self._max_histories(),
"ensemble_name": self.__module__ + "." + self.__class__.__name__,
"policy_names": policy_names
"policy_names": policy_names,
"trained_at": self.date_trained
}

utils.dump_obj_as_json_to_file(domain_spec_path, metadata)
Expand Down

0 comments on commit f22a888

Please sign in to comment.