(core) ensure randomness works when sandbox is cloned from a checkpoint

Summary:
This calls a new `initialize` method on the sandbox before we start
doing calculations with it, to make sure that `random.seed()` has
been called. Otherwise, if the sandbox is cloned from a checkpoint,
the seed will have been reset.

The `initialize` method includes the functionality previously done
by `set_doc_url` since it is also initialization/personalization and
this way we avoid introducing another round trip to the sandbox.

Test Plan: tested with grist-core configured to use gvisor

Reviewers: georgegevoian, dsagal

Reviewed By: georgegevoian, dsagal

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D3549
This commit is contained in:
Paul Fitzpatrick
2022-07-27 14:19:41 -04:00
parent 364715eba3
commit 7078922a65
3 changed files with 10 additions and 9 deletions

View File

@@ -15,10 +15,6 @@ from functions.info import ISNUMBER, ISLOGICAL
from functions.unimplemented import unimplemented
import roman
if os.environ.get("DETERMINISTIC_MODE"):
random.seed(1)
# Iterates through elements of iterable arguments, or through individual args when not iterable.
def _chain(*values_or_iterables):
for v in values_or_iterables: