Skip to content

Commit 5274776

Browse files
Custom web flow for now
1 parent e619552 commit 5274776

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+11700
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ruff: noqa: E402
2+
"""imports interfaces for interacting with server"""
3+
4+
from __future__ import annotations
5+
6+
from tidy3d.log import get_logging_console, log
7+
from tidy3d.version import __version__
8+
9+
from .core import core_config
10+
11+
# set logger to tidy3d.log before it's invoked in other imports
12+
core_config.set_config(log, get_logging_console(), __version__)
13+
14+
# from .api.asynchronous import run_async # NOTE: we use autograd one now (see below)
15+
# autograd compatible wrappers for run and run_async
16+
from .api.autograd.autograd import run, run_async
17+
from .api.container import Batch, BatchData, Job
18+
from .api.webapi import (
19+
abort,
20+
account,
21+
delete,
22+
delete_old,
23+
download,
24+
download_json,
25+
download_log,
26+
estimate_cost,
27+
get_info,
28+
get_tasks,
29+
load,
30+
load_simulation,
31+
monitor,
32+
real_cost,
33+
start,
34+
test,
35+
# run, # NOTE: use autograd one now (see below)
36+
upload,
37+
)
38+
from .cli import tidy3d_cli
39+
from .cli.app import configure_fn as configure
40+
from .cli.migrate import migrate
41+
42+
migrate()
43+
44+
__all__ = [
45+
"Batch",
46+
"BatchData",
47+
"Job",
48+
"abort",
49+
"account",
50+
"configure",
51+
"delete",
52+
"delete_old",
53+
"download",
54+
"download_json",
55+
"download_log",
56+
"estimate_cost",
57+
"get_info",
58+
"get_tasks",
59+
"load",
60+
"load_simulation",
61+
"monitor",
62+
"real_cost",
63+
"run",
64+
"run_async",
65+
"start",
66+
"test",
67+
"tidy3d_cli",
68+
"upload",
69+
]

tidy3d/plugins/smatrix/web/api/__init__.py

Whitespace-only changes.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"""Interface to run several jobs in batch using simplified syntax."""
2+
3+
from __future__ import annotations
4+
5+
from typing import Literal, Optional, Union
6+
7+
from tidy3d.log import log
8+
from tidy3d.web.core.types import PayType
9+
10+
from .container import DEFAULT_DATA_DIR, Batch, BatchData
11+
from .tidy3d_stub import SimulationType
12+
13+
14+
def run_async(
15+
simulations: dict[str, SimulationType],
16+
folder_name: str = "default",
17+
path_dir: str = DEFAULT_DATA_DIR,
18+
callback_url: Optional[str] = None,
19+
num_workers: Optional[int] = None,
20+
verbose: bool = True,
21+
simulation_type: str = "tidy3d",
22+
parent_tasks: Optional[dict[str, list[str]]] = None,
23+
reduce_simulation: Literal["auto", True, False] = "auto",
24+
pay_type: Union[PayType, str] = PayType.AUTO,
25+
) -> BatchData:
26+
"""Submits a set of Union[:class:`.Simulation`, :class:`.HeatSimulation`, :class:`.EMESimulation`] objects to server,
27+
starts running, monitors progress, downloads, and loads results as a :class:`.BatchData` object.
28+
29+
.. TODO add example and see also reference.
30+
31+
Parameters
32+
----------
33+
simulations : Dict[str, Union[:class:`.Simulation`, :class:`.HeatSimulation`, :class:`.EMESimulation`]]
34+
Mapping of task name to simulation.
35+
folder_name : str = "default"
36+
Name of folder to store each task on web UI.
37+
path_dir : str
38+
Base directory where data will be downloaded, by default current working directory.
39+
callback_url : str = None
40+
Http PUT url to receive simulation finish event. The body content is a json file with
41+
fields ``{'id', 'status', 'name', 'workUnit', 'solverVersion'}``.
42+
num_workers: int = None
43+
Number of tasks to submit at once in a batch, if None, will run all at the same time.
44+
verbose : bool = True
45+
If ``True``, will print progressbars and status, otherwise, will run silently.
46+
reduce_simulation: Literal["auto", True, False] = "auto"
47+
Whether to reduce structures in the simulation to the simulation domain only. Note: currently only implemented for the mode solver.
48+
pay_type: Union[PayType, str] = PayType.AUTO
49+
Specify the payment method.
50+
51+
Returns
52+
------
53+
:class:`BatchData`
54+
Contains the Union[:class:`.SimulationData`, :class:`.HeatSimulationData`, :class:`.EMESimulationData`] for each
55+
Union[:class:`.Simulation`, :class:`.HeatSimulation`, :class:`.EMESimulation`] in :class:`Batch`.
56+
57+
See Also
58+
--------
59+
60+
:class:`Job`:
61+
Interface for managing the running of a Simulation on server.
62+
63+
:class:`Batch`
64+
Interface for submitting several :class:`Simulation` objects to sever.
65+
"""
66+
if simulation_type is None:
67+
simulation_type = "tidy3d"
68+
69+
# if number of workers not specified, just use the number of simulations
70+
if num_workers is not None:
71+
log.warning(
72+
"The 'num_workers' kwarg does not have an effect anymore as all "
73+
"simulations will now be uploaded in a single batch."
74+
)
75+
76+
batch = Batch(
77+
simulations=simulations,
78+
folder_name=folder_name,
79+
callback_url=callback_url,
80+
verbose=verbose,
81+
simulation_type=simulation_type,
82+
parent_tasks=parent_tasks,
83+
reduce_simulation=reduce_simulation,
84+
pay_type=pay_type,
85+
)
86+
87+
batch_data = batch.run(path_dir=path_dir)
88+
return batch_data

tidy3d/plugins/smatrix/web/api/autograd/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)