You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2014/02/23 05:45:25 UTC
svn commit: r1570973 - in /incubator/climate/trunk/ocw-ui/backend:
processing.py tests/test_processing.py
Author: joyce
Date: Sun Feb 23 04:45:24 2014
New Revision: 1570973
URL: http://svn.apache.org/r1570973
Log:
CLIMATE-332 - Add directory result versioning
- Add directory versioning in plot generation.
- Add eval_time_stamp parameter to unary/binary plot title generation
helper to properly version results.
- Update plot path generation helpers to include time stamp versioning.
Modified:
incubator/climate/trunk/ocw-ui/backend/processing.py
incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py
Modified: incubator/climate/trunk/ocw-ui/backend/processing.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw-ui/backend/processing.py?rev=1570973&r1=1570972&r2=1570973&view=diff
==============================================================================
--- incubator/climate/trunk/ocw-ui/backend/processing.py (original)
+++ incubator/climate/trunk/ocw-ui/backend/processing.py Sun Feb 23 04:45:24 2014
@@ -411,7 +411,10 @@ def _generate_evaluation_plots(evaluatio
:raises ValueError: If there aren't any results to graph.
'''
- # TODO: Need to take into consideration the results 'versioning' that the backend currently uses
+ # Create time stamp version-ed WORK_DIR for plotting
+ eval_time_stamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
+ eval_path = os.path.join(WORK_DIR, eval_time_stamp)
+ os.makedirs(eval_path)
# TODO: Should be able to check for None here...
if evaluation.results == [] and evaluation.unary_results == []:
@@ -433,7 +436,8 @@ def _generate_evaluation_plots(evaluatio
results = evaluation.results[dataset_index][metric_index]
file_name = _generate_binary_eval_plot_file_path(evaluation,
dataset_index,
- metric_index)
+ metric_index,
+ eval_time_stamp)
plot_title = _generate_binary_eval_plot_title(evaluation,
dataset_index,
metric_index)
@@ -451,7 +455,8 @@ def _generate_evaluation_plots(evaluatio
for result_index, result in enumerate(cur_unary_results):
file_name = _generate_unary_eval_plot_file_path(evaluation,
result_index,
- metric_index)
+ metric_index,
+ eval_time_stamp)
plot_title = _generate_unary_eval_plot_title(evaluation,
result_index,
metric_index)
@@ -485,7 +490,8 @@ def _calculate_grid_shape(reference_data
return (num_rows, max_cols)
-def _generate_binary_eval_plot_file_path(evaluation, dataset_index, metric_index):
+def _generate_binary_eval_plot_file_path(evaluation, dataset_index,
+ metric_index, time_stamp):
''' Generate a plot path for a given binary metric run.
:param evaluation: The Evaluation object from which to pull name information.
@@ -505,9 +511,11 @@ def _generate_binary_eval_plot_file_path
evaluation.metrics[metric_index].__class__.__name__.lower()
)
- return os.path.join(WORK_DIR, plot_name)
+ timestamped_workdir = os.path.join(WORK_DIR, time_stamp)
+ return os.path.join(timestamped_workdir, plot_name)
-def _generate_unary_eval_plot_file_path(evaluation, dataset_index, metric_index):
+def _generate_unary_eval_plot_file_path(evaluation, dataset_index,
+ metric_index, time_stamp):
''' Generate a plot path for a given unary metric run.
:param evaluation: The Evaluation object from which to pull name information.
@@ -522,6 +530,7 @@ def _generate_unary_eval_plot_file_path(
be placed in the WORK_DIR set for the web services.
'''
metric = evaluation.unary_metrics[metric_index]
+ timestamped_workdir = os.path.join(WORK_DIR, time_stamp)
# Unary metrics can be run over both the reference dataset and the target
# datasets. It's possible for an evaluation to only have one and not the
@@ -536,7 +545,7 @@ def _generate_unary_eval_plot_file_path(
metric.__class__.__name__.lower()
)
- return os.path.join(WORK_DIR, plot_name)
+ return os.path.join(timestamped_workdir, plot_name)
else:
dataset_index -= 1
@@ -545,7 +554,7 @@ def _generate_unary_eval_plot_file_path(
metric.__class__.__name__.lower()
)
- return os.path.join(WORK_DIR, plot_name)
+ return os.path.join(timestamped_workdir, plot_name)
def _generate_binary_eval_plot_title(evaluation, dataset_index, metric_index):
''' Generate a plot title for a given binary metric run.
Modified: incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py?rev=1570973&r1=1570972&r2=1570973&view=diff
==============================================================================
--- incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py (original)
+++ incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py Sun Feb 23 04:45:24 2014
@@ -159,31 +159,49 @@ class TestFilePathCreation(unittest.Test
)
def test_binary_metric_path_generation(self):
+ time_stamp = dt.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
self.assertEquals(
- bp._generate_binary_eval_plot_file_path(self.full_evaluation, 0, 1),
- '/tmp/ocw/ref_compared_to_t1_bias'
+ bp._generate_binary_eval_plot_file_path(self.full_evaluation,
+ 0, # dataset_index
+ 1, # metric_index
+ time_stamp),
+ '/tmp/ocw/{}/ref_compared_to_t1_bias'.format(time_stamp)
)
def test_unary_metric_path_generation_full_eval(self):
+ time_stamp = dt.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
self.assertEquals(
- bp._generate_unary_eval_plot_file_path(self.full_evaluation, 0, 0),
- '/tmp/ocw/ref_temporalstddev'
+ bp._generate_unary_eval_plot_file_path(self.full_evaluation,
+ 0, # dataset_index
+ 0, # metric_index
+ time_stamp),
+ '/tmp/ocw/{}/ref_temporalstddev'.format(time_stamp)
)
self.assertEquals(
- bp._generate_unary_eval_plot_file_path(self.full_evaluation, 1, 0),
- '/tmp/ocw/t1_temporalstddev'
+ bp._generate_unary_eval_plot_file_path(self.full_evaluation,
+ 1, # dataset_index
+ 0, # metric_index
+ time_stamp),
+ '/tmp/ocw/{}/t1_temporalstddev'.format(time_stamp)
)
def test_unary_metric_path_generation_partial_eval(self):
+ time_stamp = dt.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
self.assertEquals(
- bp._generate_unary_eval_plot_file_path(self.unary_evaluation, 0, 0),
- '/tmp/ocw/t1_temporalstddev'
+ bp._generate_unary_eval_plot_file_path(self.unary_evaluation,
+ 0, # dataset_index
+ 0, # metric_index
+ time_stamp),
+ '/tmp/ocw/{}/t1_temporalstddev'.format(time_stamp)
)
self.assertEquals(
- bp._generate_unary_eval_plot_file_path(self.unary_evaluation, 1, 0),
- '/tmp/ocw/t2_temporalstddev'
+ bp._generate_unary_eval_plot_file_path(self.unary_evaluation,
+ 1, # dataset_index
+ 0, # metric_index
+ time_stamp),
+ '/tmp/ocw/{}/t2_temporalstddev'.format(time_stamp)
)
class TestPlotTitleCreation(unittest.TestCase):