From 143efcf1855c631dd6b72aa341011ddc3c2d11a9 Mon Sep 17 00:00:00 2001 From: momchil Date: Fri, 25 Oct 2024 13:29:49 +0200 Subject: [PATCH] Pre-upload validating server autograd runs and optimizer --- tests/test_plugins/test_invdes.py | 1 + tidy3d/plugins/invdes/optimizer.py | 2 +- tidy3d/web/api/autograd/autograd.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_plugins/test_invdes.py b/tests/test_plugins/test_invdes.py index 75e6b7498..b96d7e9ab 100644 --- a/tests/test_plugins/test_invdes.py +++ b/tests/test_plugins/test_invdes.py @@ -297,6 +297,7 @@ def make_result(use_emulated_run): # noqa: F811 """Test running the optimization defined in the ``InverseDesign`` object.""" optimizer = make_optimizer() + optimizer.validate_pre_upload() return optimizer.run(post_process_fn=post_process_fn) diff --git a/tidy3d/plugins/invdes/optimizer.py b/tidy3d/plugins/invdes/optimizer.py index 79e0ba3b2..08758f12b 100644 --- a/tidy3d/plugins/invdes/optimizer.py +++ b/tidy3d/plugins/invdes/optimizer.py @@ -73,7 +73,7 @@ def initial_state(self, parameters: np.ndarray) -> dict: def validate_pre_upload(self) -> None: """Validate the fully initialized optimizer is ok for upload to our servers.""" - pass + self.design.simulation.validate_pre_upload() def display_fn(self, result: InverseDesignResult, step_index: int) -> None: """Default display function while optimizing.""" diff --git a/tidy3d/web/api/autograd/autograd.py b/tidy3d/web/api/autograd/autograd.py index 5abe68967..646d5a316 100644 --- a/tidy3d/web/api/autograd/autograd.py +++ b/tidy3d/web/api/autograd/autograd.py @@ -410,6 +410,7 @@ def _run_primitive( ) else: + sim_combined.validate_pre_upload() sim_original = sim_original.updated_copy(simulation_type="autograd_fwd", deep=False) run_kwargs["simulation_type"] = "autograd_fwd" run_kwargs["sim_fields_keys"] = list(sim_fields.keys())