Skip to content

Commit a4b8c92

Browse files
authored
Merge pull request #986 from CitrineInformatics/speed-up-ds-unit-test
Speed up DS unit test.
2 parents 7eac254 + 29312b3 commit a4b8c92

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/citrine/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.15.0"
1+
__version__ = "3.15.1"

tests/resources/test_design_space.py

+26-12
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,37 @@ def test_design_space_limits():
133133
# Given
134134
session = FakeSession()
135135
collection = DesignSpaceCollection(uuid.uuid4(), session)
136+
137+
descriptors = [RealDescriptor(f"R-{i}", lower_bound=0, upper_bound=1, units="") for i in range(128)]
138+
descriptor_values = {f"R-{i}": str(random.random()) for i in range(128)}
136139

137-
too_big = EnumeratedDesignSpace(
138-
"foo",
139-
description="bar",
140-
descriptors=[RealDescriptor("R-{}".format(i), lower_bound=0, upper_bound=1, units="") for i in range(128)],
141-
data=[{f"R-{i}": str(random.random()) for i in range(128)} for _ in range(2001)]
140+
just_right = EnumeratedDesignSpace(
141+
"just right",
142+
description="just right desc",
143+
descriptors=descriptors,
144+
data=[descriptor_values] * 2000
142145
)
143146

144-
just_right = EnumeratedDesignSpace(
145-
"foo",
146-
description="bar",
147-
descriptors=[RealDescriptor("R-{}".format(i), lower_bound=0, upper_bound=1, units="") for i in range(128)],
148-
data=[{f"R-{i}": str(random.random()) for i in range(128)} for _ in range(2000)]
147+
too_big = EnumeratedDesignSpace(
148+
"too big",
149+
description="too big desc",
150+
descriptors=just_right.descriptors,
151+
data=[descriptor_values] * 2001
149152
)
150153

151-
# create mock post response by setting the status
152-
mock_response = _ds_to_response(just_right, status="READY")
154+
# create mock post response by setting the status.
155+
# Deserializing that huge dict takes a long time, and it's done twice when making a call to
156+
# register or update (the second is the automatic validation kick-off). Since we're only
157+
# interested in checking the validation pre-request, we can specify a tiny response to speed up
158+
# the test execution.
159+
dummy_desc = descriptors[0]
160+
dummy_resp = EnumeratedDesignSpace(
161+
"basic",
162+
description="basic desc",
163+
descriptors=[dummy_desc],
164+
data=[{dummy_desc.key: descriptor_values[dummy_desc.key]}]
165+
)
166+
mock_response = _ds_to_response(dummy_resp, status="READY")
153167
session.responses.append(mock_response)
154168

155169
# Then

0 commit comments

Comments
 (0)