Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made run time optional, but must be >0 to upload #262

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions tidy3d/components/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ class Simulation(Box): # pylint:disable=too-many-public-methods
units=MICROMETER,
)

run_time: pydantic.PositiveFloat = pydantic.Field(
...,
run_time: pydantic.NonNegativeFloat = pydantic.Field(
0.0,
title="Run Time",
description="Total electromagnetic evolution time in seconds. "
"Note: If simulation 'shutoff' is specified, "
"simulation will terminate early when shutoff condition met.",
"simulation will terminate early when shutoff condition met. "
"Must be set > 0 before running Simulation on our servers.",
units=SECOND,
)

Expand Down Expand Up @@ -468,10 +469,11 @@ def _plane_wave_homogeneous(cls, val, values):

""" Pre submit validation (before web.upload()) """

def validate_contents(self) -> None:
"""Validate the fully initialized simulation is within allowed limits."""
def validate_pre_upload(self) -> None:
"""Validate the fully initialized simulation is ok for upload to our servers."""
self._validate_size()
self._validate_monitor_size()
self._validate_run_time()

def _validate_size(self) -> None:
"""Ensures the simulation is within size limits before simulation is uploaded."""
Expand Down Expand Up @@ -516,6 +518,15 @@ def _validate_monitor_size(self) -> None:
f"a maximum of {MAX_MONITOR_DATA_SIZE_BYTES:.2e} are allowed."
)

def _validate_run_time(self) -> None:
"""Ensures that the simulation run time is > 0."""

if not self.run_time > 0:
raise SetupError(
"The `Simulation.run_time` parameter was left at its default value of 0.0. "
"For running a simulation on our servers it must be set to > 0.0."
)

""" Accounting """

@property
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/web/webapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def _upload_task( # pylint:disable=too-many-locals,too-many-arguments
) -> TaskId:
"""upload with all kwargs exposed"""

simulation.validate_contents()
simulation.validate_pre_upload()

json_string = simulation._json_string() # pylint:disable=protected-access
data = {
Expand Down