Skip to content

flex_rf.web.Job

Type: class Base(s): WebContainer

Interface for managing the running of a Simulation on server.

This class provides a more convenient way to manage single simulations, mainly because it eliminates the need for keeping track of the task_id and original Simulation.

We can get the cost estimate of running the task before actually running it. This prevents us from accidentally running large jobs that we set up by mistake. The estimated cost is the maximum cost corresponding to running all the time steps.

Another convenient thing about Job objects is that they can be saved and loaded just like other tidy3d components.

Once you’ve created a job object using Job, you can upload it to our servers with:

tidy3d.web.upload(simulation, task_name="task_name", verbose=verbose)

It will not run until you explicitly tell it to do so with:

tidy3d.web.api.webapi.start(job.task_id)

To monitor the simulation’s progress and wait for its completion, use

tidy3d.web.api.webapi.monitor(job.task_id, verbose=verbose)

After running the simulation, you can load the results using for example:

sim_data = tidy3d.web.api.webapi.load(job.task_id, path="out/simulation.hdf5", verbose=verbose)

The job container has a convenient method to save and load the results of a job that has already finished, without needing to know the task_id, as below:

# Saves the job metadata to a single file.
job.to_file("data/job.json")
# You can exit the session, break here, or continue in new session.
# Load the job metadata from file.
job_loaded = tidy3d.web.api.container.Job.from_file("data/job.json")
# Download the data from the server and load it into a SimulationData object.
sim_data = job_loaded.load(path="data/sim.hdf5")
simulation [WorkflowType]

Simulation to run as a ‘task’.

task_name [TaskName | None] = None

Unique name of the task. Will be auto-generated if not provided.

folder_name [str] = 'default'

Name of folder to store task on web UI.

callback_url [str | None] = None

Http PUT url to receive simulation finish event. The body content is a json file with fields {'id', 'status', 'name', 'workUnit', 'solverVersion'}.

solver_version [str | None] = None

Custom solver version to use, otherwise uses default for the current front end version.

verbose [bool] = True

Whether to print info messages and progressbars.

simulation_type [BatchCategoryType | None] = None

Type of simulation, used internally only.

parent_tasks [tuple[TaskId, ...] | None] = None

Tuple of parent task ids, used internally only.

task_id_cached [TaskId | None] = None

Optional field to specify task_id. Only used as a workaround internally so that task_id is written when Job.to_file() and then the proper task is loaded from Job.from_file(). We recommend leaving unset as setting this field along with fields that were not used to create the task will cause errors.

reduce_simulation [Literal['auto', True, False]] = 'auto'

Whether to reduce structures in the simulation to the simulation domain only. Note: currently only implemented for the mode solver.

pay_type [PayType | None] = None

Specify the payment method.

lazy [bool] = False

Whether to load the actual data (lazy=False) or return a proxy that loads the data when accessed (lazy=True).

status [str]

Return current status of Job.

clear_stash()

Delete this job’s stash file only.

delete()

Delete server-side data associated with Job.

download(path: PathLike | None = None)

Download results of simulation.

estimate_cost(verbose: bool = True)

Compute the maximum FlexCredit charge for a given Job.

get_info()

Return information about a Job.

get_run_info()

Return information about the running Job.

load(path: PathLike | None = None)

Download job results and load them into a data object.

load_if_cached()

Checks if results are cached and (if yes) restores them into our shared stash file.

monitor()

Monitor progress of running Job.

real_cost(verbose: bool = True)

Get the billed cost for the task associated with this job.

run(path: PathLike | None = None, priority: int | None = None, vgpu_allocation: int | None = None, ignore_memory_limit: bool | None = None)

Run Job all the way through and return data.

set_task_name_if_none(data: dict[str, Any])

Auto-assign a task_name if user did not provide one.

start(priority: int | None = None, vgpu_allocation: int | None = None, ignore_memory_limit: bool | None = None)

Start running a Job.

task_id()

The task ID for this Job. Uploads the Job if it hasn’t already been uploaded.

to_file(fname: PathLike)

Exports Tidy3dBaseModel instance to .yaml, .json, or .hdf5 file

upload()

Upload this Job if not already got cached results.