[yt-svn] commit/yt: ngoldbaum: Merged in xarthisius/yt (pull request #2422)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Oct 27 13:02:38 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/aff20fbf4037/
Changeset: aff20fbf4037
Branch: yt
User: ngoldbaum
Date: 2016-10-27 20:02:11+00:00
Summary: Merged in xarthisius/yt (pull request #2422)
Do not store answers if required dataset is not present
Affected #: 7 files
diff -r d15775018c266934317e4021fad305b4d37e08c5 -r aff20fbf4037f400504edd7d33c88aff92858dbb doc/source/reference/configuration.rst
--- a/doc/source/reference/configuration.rst
+++ b/doc/source/reference/configuration.rst
@@ -95,6 +95,10 @@
IPython notebook created by ``yt notebook``. Note that this should be an
sha512 hash, not a plaintext password. Starting ``yt notebook`` with no
setting will provide instructions for setting this.
+* ``requires_ds_strict`` (default: ``'True'``): If true, answer tests wrapped
+ with :func:`~yt.utilities.answer_testing.framework.requires_ds` will raise
+ :class:`~yt.utilities.exceptions.YTOutputNotIdentified` rather than consuming
+ it if required dataset is not present.
* ``serialize`` (default: ``'False'``): If true, perform automatic
:ref:`object serialization <object-serialization>`
* ``sketchfab_api_key`` (default: empty): API key for https://sketchfab.com/ for
diff -r d15775018c266934317e4021fad305b4d37e08c5 -r aff20fbf4037f400504edd7d33c88aff92858dbb yt/config.py
--- a/yt/config.py
+++ b/yt/config.py
@@ -48,6 +48,7 @@
reconstruct_index = 'False',
test_storage_dir = '/does/not/exist',
test_data_dir = '/does/not/exist',
+ requires_ds_strict = 'False',
enzo_db = '',
hub_url = 'https://girder.hub.yt/api/v1',
hub_api_key = '',
diff -r d15775018c266934317e4021fad305b4d37e08c5 -r aff20fbf4037f400504edd7d33c88aff92858dbb yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -229,7 +229,13 @@
class AnswerTestLocalStorage(AnswerTestStorage):
def dump(self, result_storage):
- if self.answer_name is None: return
+ # The 'tainted' attribute is automatically set to 'True'
+ # if the dataset required for an answer test is missing
+ # (see can_run_ds() and can_run_sim()).
+ # This logic check prevents creating a shelve with empty answers.
+ storage_is_tainted = result_storage.get('tainted', False)
+ if self.answer_name is None or storage_is_tainted:
+ return
# Store data using shelve
ds = shelve.open(self.answer_name, protocol=-1)
for ds_name in result_storage:
@@ -259,34 +265,44 @@
os.chdir(oldcwd)
def can_run_ds(ds_fn, file_check = False):
+ result_storage = AnswerTestingTest.result_storage
if isinstance(ds_fn, Dataset):
- return AnswerTestingTest.result_storage is not None
+ return result_storage is not None
path = ytcfg.get("yt", "test_data_dir")
if not os.path.isdir(path):
return False
if file_check:
return os.path.isfile(os.path.join(path, ds_fn)) and \
- AnswerTestingTest.result_storage is not None
+ result_storage is not None
try:
load(ds_fn)
except YTOutputNotIdentified:
+ if ytcfg.getboolean("yt", "requires_ds_strict"):
+ if result_storage is not None:
+ result_storage['tainted'] = True
+ raise
return False
- return AnswerTestingTest.result_storage is not None
+ return result_storage is not None
def can_run_sim(sim_fn, sim_type, file_check = False):
+ result_storage = AnswerTestingTest.result_storage
if isinstance(sim_fn, SimulationTimeSeries):
- return AnswerTestingTest.result_storage is not None
+ return result_storage is not None
path = ytcfg.get("yt", "test_data_dir")
if not os.path.isdir(path):
return False
if file_check:
return os.path.isfile(os.path.join(path, sim_fn)) and \
- AnswerTestingTest.result_storage is not None
+ result_storage is not None
try:
simulation(sim_fn, sim_type)
except YTOutputNotIdentified:
+ if ytcfg.getboolean("yt", "requires_ds_strict"):
+ if result_storage is not None:
+ result_storage['tainted'] = True
+ raise
return False
- return AnswerTestingTest.result_storage is not None
+ return result_storage is not None
def data_dir_load(ds_fn, cls = None, args = None, kwargs = None):
args = args or ()
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list