Skip to content

Commit

Permalink
Making get_dataset() in regression utils use a global.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Oct 27, 2014
1 parent a71c4b2 commit 4af407a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions regression/regression_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DATASET_ID = os.getenv('GCLOUD_TESTS_DATASET_ID')
CLIENT_EMAIL = os.getenv('GCLOUD_TESTS_CLIENT_EMAIL')
KEY_FILENAME = os.getenv('GCLOUD_TESTS_KEY_FILE')
DATASETS = {}

ENVIRON_ERROR_MSG = """\
To run the regression tests, you need to set some environment variables.
Expand All @@ -28,11 +29,10 @@ def get_environ():


def get_dataset():
if get_dataset.cached_result is None:
environ = get_environ()
# Cache value on the function.
get_dataset.cached_result = datastore.get_dataset(
environ['dataset_id'], environ['client_email'],
environ['key_filename'])
return get_dataset.cached_result
get_dataset.cached_result = None
environ = get_environ()
get_dataset_args = (environ['dataset_id'], environ['client_email'],
environ['key_filename'])
if get_dataset_args not in DATASETS:
# Cache return value for the environment.
DATASETS[get_dataset_args] = datastore.get_dataset(*get_dataset_args)
return DATASETS[get_dataset_args]
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ deps =
basepython =
python2.7
commands =
rm -fr docs/_build
python -c "import shutil; shutil.rmtree('docs/_build', ignore_errors=True)"
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
deps =
Sphinx
Expand Down

0 comments on commit 4af407a

Please sign in to comment.