Skip to content

Commit

Permalink
updated metrics to save as csv instead of json
Browse files Browse the repository at this point in the history
  • Loading branch information
williamFalcon committed Feb 9, 2018
1 parent 4d07a97 commit 4eae876
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test_tube/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def save(self):
# file name
self.__save_images(self.metrics)
metrics_file_path = self.get_data_path(self.name, self.version) + '/metrics.csv'
meta_tags_path = self.get_data_path(self.name, self.version) + '/meta_tags.json'
meta_tags_path = self.get_data_path(self.name, self.version) + '/meta_tags.csv'

obj = {
'name': self.name,
Expand All @@ -240,15 +240,13 @@ def save(self):
json.dump(obj, file, ensure_ascii=False)

# save the metatags file
with open(meta_tags_path, 'w') as file:
json.dump(self.tags, file, ensure_ascii=False)
df = pd.DataFrame({'key': list(self.tags.keys()), 'value': list(self.tags.values())})
df.to_csv(meta_tags_path, index=False)

# save the metrics data
df = pd.DataFrame(self.metrics)
df.to_csv(metrics_file_path, index=False)



def __save_images(self, metrics):
"""
Save tags that have a png_ prefix (as images)
Expand Down Expand Up @@ -290,10 +288,9 @@ def __load(self):
self.exp_hash = data['exp_hash']

# load .tags file
meta_tags_path = self.get_data_path(self.name, self.version) + '/meta_tags.json'
with open(meta_tags_path, 'r') as file:
data = json.load(file)
self.tags = data
meta_tags_path = self.get_data_path(self.name, self.version) + '/meta_tags.csv'
df = pd.read_csv(meta_tags_path)
self.tags = df.to_dict(orient='records')

# load metrics
metrics_file_path = self.get_data_path(self.name, self.version) + '/metrics.csv'
Expand Down

0 comments on commit 4eae876

Please sign in to comment.