From a8aced2135a40d75a3f97004bff1959d42791404 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Tue, 20 Feb 2024 10:27:50 +0000 Subject: [PATCH] Tweak store tests --- src/jobflow_remote/testing/__init__.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/jobflow_remote/testing/__init__.py b/src/jobflow_remote/testing/__init__.py index e3d6362a..048e5005 100644 --- a/src/jobflow_remote/testing/__init__.py +++ b/src/jobflow_remote/testing/__init__.py @@ -43,16 +43,20 @@ def check_env_var() -> str: return os.environ.get("TESTING_ENV_VAR", "unset") -@job(big_files="data") +@job def add_big(a: float, b: float): - """Adds two numbers together and writes the answer to an artificially large file - which is stored in a pre-defined store.""" - import pathlib + """Adds two numbers together and inflates the answer + to an array too large to store in MongoDB, then tries + to store that within the defined store. + + """ + import array result = a + b - with open("file.txt", "w") as f: - f.writelines([f"{result}"] * int(1e5)) - return Response({"data": pathlib.Path("file.txt"), "result": a + b}) + # create a 1.6 MB array that will be too large to store in MongoDB + # the array type "d" is a double-precision float, which is 8 bytes + big_array = array.array("d", [result] * 200_000) + return Response({"data": big_array, "result": a + b}) @job(undefined_store="data")