This is a python package associate with Tidy3 for https://tidy3d.simulation.cloud operations.
The design Philosophy of this package is inspired by Active Record of Ruby on Rails, here are basic ideas:
- Class methods are used to query and creation.
- Instance methods are used to update and delete.
pip install tidy3d-webapi
The API key can be found in tidy3d user profile page. There are three ways to setup the API key:
Run below command line and flow instructions:
tidy3d configure
mkdir ~/.tidy3d
echo "SIMCLOUD_APIKEY=tidy3d-25c3ad97-372f-4633-a94f-d4d2be598146" > ~/.tidy3d/config
Please notice that the environment variable will override the configuration file.
export SIMCLOUD_APIKEY="tidy3d-api-key"
from tidy3d_webapi import Tidy3DFolder
folders = Tidy3dFolder.list()
default_folder = Tidy3dFolder.get("default")
new_folder = Tidy3DFolder.create(name="new_folder")
import os
import tempfile
from tidy3d_webapi import Tidy3DFolder, Tidy3DTask
default_folder = Tidy3dFolder.get("default")
tasks = default_folder.list_tasks()
task = Tidy3DTask.get_task("3eb06d16-208b-487b-864b-e9b1d3e010a7")
with tempfile.NamedTemporaryFile() as temp:
task.get_simulation_json(temp.name)
assert os.path.exists(temp.name)
sim = task.get_simulation()
sim = Simulation.from_file("simulation.json")
task = Tidy3DTask.create(sim, task_name="test task", folder_name="test folder2")
task = Tidy3DTask.get_task("3eb06d16-208b-487b-864b-e9b1d3e010a7")
sim = task.get_simulation()
task = Tidy3DTask.create(sim, "test task", "test folder1")
task.submit(protocol_version="1.6.3")
task = Tidy3DTask.get_task("3eb06d16-208b-487b-864b-e9b1d3e010a7")
task.remove()
from tidy3d_webapi.material_libray import MaterialLibray
libs = MaterialLibray.list()
lib = libs[0]
assert lib.medium
import time
from tidy3d.plugins import DispersionFitter
from tidy3d_webapi.material_fitter import FitterOptions, MaterialFitterTask
fitter = DispersionFitter.from_file("data/nk_data.csv", skiprows=1, delimiter=",")
task = MaterialFitterTask.create(fitter, FitterOptions())
retry = 0
max_retry = 12
waiting_sec = 10
while retry < max_retry:
task.sync_status() # sync fitter status
retry += 1
if task.status == "COMPLETED":
break
if task.status != "COMPLETED":
time.sleep(waiting_sec)
assert task.status == "COMPLETED"
assert task.save_to_library("test_material") # save to library
- Install poetry
- Install dependencies:
poetry install
- enable pre-commit hooks for pylint and code reformat
poetry run autohooks activate --mode poetry
poetry run pytest
black .
pylint tidy3d_webapi --rcfile .pylintrc