Skip to content

Commit

Permalink
Deprecate test_session() and introduce instead session() and cached_s…
Browse files Browse the repository at this point in the history
…ession().

Implicitly, test_session(graph=None,...) will by default cache the session and thus the object will not be deleted if used in a with statement:

with self.test_session():
  # Some code
# Some other code where by default we would expect that the session is closed by now.

The fact that the session is not closed when we exit the with scope has caused surprise to users and created hard to diagnose bugs. To keep backward compatibility, we are deprecating this function and introducing a new one called cached_session that will by default always cache the session (even when graph is not None) and a new function where session will always be closed.

Note that the behavior of test_session has slightly changed as it will always set the graph and session as global default (with as_default).

The documentation of test_session has also changed as the documentation was not matching the previous behavior of test_session.

PiperOrigin-RevId: 209511997
  • Loading branch information
tensorflower-gardener committed Aug 21, 2018
1 parent a4404f6 commit 9962eb5
Show file tree
Hide file tree
Showing 2 changed files with 244 additions and 94 deletions.

0 comments on commit 9962eb5

Please sign in to comment.