{
  "title": "Job",
  "public_path": "flex_rf.web.Job",
  "lookup_path": "tidy3d.web.Job",
  "slug": "flex_rf/web/Job",
  "public_url": "/rf/latest/autogenerated/flex_rf/web/job/",
  "object_kind": "class",
  "introduction": "Interface for managing the running of a `Simulation` on server.",
  "notes": "This class provides a more convenient way to manage single simulations, mainly because it eliminates the need\nfor keeping track of the `task_id` and original `Simulation`.\n\nWe can get the cost estimate of running the task before actually running it. This prevents us from\naccidentally running large jobs that we set up by mistake. The estimated cost is the maximum cost\ncorresponding to running all the time steps.\n\nAnother convenient thing about `Job` objects is that they can be saved and loaded just like other\n`tidy3d` components.",
  "examples": "Once you've created a `job` object using `Job`, you can upload it to our servers with:\n\n```python\ntidy3d.web.upload(simulation, task_name=\"task_name\", verbose=verbose)\n```\n\nIt will not run until you explicitly tell it to do so with:\n\n```python\ntidy3d.web.api.webapi.start(job.task_id)\n```\n\nTo monitor the simulation's progress and wait for its completion, use\n\n```python\ntidy3d.web.api.webapi.monitor(job.task_id, verbose=verbose)\n```\n\nAfter running the simulation, you can load the results using for example:\n\n```python\nsim_data = tidy3d.web.api.webapi.load(job.task_id, path=\"out/simulation.hdf5\", verbose=verbose)\n```\n\nThe job container has a convenient method to save and load the results of a job that has already finished,\nwithout needing to know the task_id, as below:\n\n```python\n# Saves the job metadata to a single file.\njob.to_file(\"data/job.json\")\n\n# You can exit the session, break here, or continue in new session.\n\n# Load the job metadata from file.\njob_loaded = tidy3d.web.api.container.Job.from_file(\"data/job.json\")\n\n# Download the data from the server and load it into a SimulationData object.\nsim_data = job_loaded.load(path=\"data/sim.hdf5\")\n```",
  "references": "",
  "signature": "class Job(WebContainer)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/web/api/container.py",
    "url": "",
    "lineno": 110,
    "endlineno": 646
  },
  "bases": [
    "WebContainer"
  ],
  "parameter_rows": [
    {
      "name": "simulation",
      "annotation": "WorkflowType",
      "default": "",
      "description": "Simulation to run as a 'task'.",
      "origin": "declared"
    },
    {
      "name": "task_name",
      "annotation": "TaskName | None",
      "default": "None",
      "description": "Unique name of the task. Will be auto-generated if not provided.",
      "origin": "declared"
    },
    {
      "name": "folder_name",
      "annotation": "str",
      "default": "'default'",
      "description": "Name of folder to store task on web UI.",
      "origin": "declared"
    },
    {
      "name": "callback_url",
      "annotation": "str | None",
      "default": "None",
      "description": "Http PUT url to receive simulation finish event. The body content is a json file with fields `{'id', 'status', 'name', 'workUnit', 'solverVersion'}`.",
      "origin": "declared"
    },
    {
      "name": "solver_version",
      "annotation": "str | None",
      "default": "None",
      "description": "Custom solver version to use, otherwise uses default for the current front end version.",
      "origin": "declared"
    },
    {
      "name": "verbose",
      "annotation": "bool",
      "default": "True",
      "description": "Whether to print info messages and progressbars.",
      "origin": "declared"
    },
    {
      "name": "simulation_type",
      "annotation": "BatchCategoryType | None",
      "default": "None",
      "description": "Type of simulation, used internally only.",
      "origin": "declared"
    },
    {
      "name": "parent_tasks",
      "annotation": "tuple[TaskId, ...] | None",
      "default": "None",
      "description": "Tuple of parent task ids, used internally only.",
      "origin": "declared"
    },
    {
      "name": "task_id_cached",
      "annotation": "TaskId | None",
      "default": "None",
      "description": "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.",
      "origin": "declared"
    },
    {
      "name": "reduce_simulation",
      "annotation": "Literal['auto', True, False]",
      "default": "'auto'",
      "description": "Whether to reduce structures in the simulation to the simulation domain only. Note: currently only implemented for the mode solver.",
      "origin": "declared"
    },
    {
      "name": "pay_type",
      "annotation": "PayType | None",
      "default": "None",
      "description": "Specify the payment method.",
      "origin": "declared"
    },
    {
      "name": "lazy",
      "annotation": "bool",
      "default": "False",
      "description": "Whether to load the actual data (lazy=False) or return a proxy that loads the data when accessed (lazy=True).",
      "origin": "declared"
    },
    {
      "name": "attrs",
      "annotation": "dict",
      "default": "factory: dict",
      "description": "Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, `attrs` are mutable. For example, the following is allowed for setting an `attr` `obj.attrs['foo'] = bar`. Also note that Tidy3D will raise a `TypeError` if `attrs` contain objects that can not be serialized. One can check if `attrs` are serializable by calling `obj.model_dump_json()`.",
      "origin": "inherited"
    }
  ],
  "members": [
    {
      "name": "clear_stash",
      "kind": "function",
      "signature": "clear_stash()",
      "description": "Delete this job's stash file only."
    },
    {
      "name": "delete",
      "kind": "function",
      "signature": "delete()",
      "description": "Delete server-side data associated with `Job`."
    },
    {
      "name": "download",
      "kind": "function",
      "signature": "download(path: PathLike | None = None)",
      "description": "Download results of simulation."
    },
    {
      "name": "estimate_cost",
      "kind": "function",
      "signature": "estimate_cost(verbose: bool = True)",
      "description": "Compute the maximum FlexCredit charge for a given `Job`."
    },
    {
      "name": "get_info",
      "kind": "function",
      "signature": "get_info()",
      "description": "Return information about a `Job`."
    },
    {
      "name": "get_run_info",
      "kind": "function",
      "signature": "get_run_info()",
      "description": "Return information about the running `Job`."
    },
    {
      "name": "load",
      "kind": "function",
      "signature": "load(path: PathLike | None = None)",
      "description": "Download job results and load them into a data object."
    },
    {
      "name": "load_if_cached",
      "kind": "function",
      "signature": "load_if_cached()",
      "description": "Checks if results are cached and (if yes) restores them into our shared stash file."
    },
    {
      "name": "monitor",
      "kind": "function",
      "signature": "monitor()",
      "description": "Monitor progress of running `Job`."
    },
    {
      "name": "real_cost",
      "kind": "function",
      "signature": "real_cost(verbose: bool = True)",
      "description": "Get the billed cost for the task associated with this job."
    },
    {
      "name": "run",
      "kind": "function",
      "signature": "run(path: PathLike | None = None, priority: int | None = None, vgpu_allocation: int | None = None, ignore_memory_limit: bool | None = None)",
      "description": "Run `Job` all the way through and return data."
    },
    {
      "name": "set_task_name_if_none",
      "kind": "function",
      "signature": "set_task_name_if_none(data: dict[str, Any])",
      "description": "Auto-assign a task_name if user did not provide one."
    },
    {
      "name": "start",
      "kind": "function",
      "signature": "start(priority: int | None = None, vgpu_allocation: int | None = None, ignore_memory_limit: bool | None = None)",
      "description": "Start running a `Job`."
    },
    {
      "name": "status",
      "kind": "attribute",
      "signature": "status: str",
      "description": "Return current status of `Job`."
    },
    {
      "name": "task_id",
      "kind": "function",
      "signature": "task_id()",
      "description": "The task ID for this `Job`. Uploads the `Job` if it hasn't already been uploaded."
    },
    {
      "name": "to_file",
      "kind": "function",
      "signature": "to_file(fname: PathLike)",
      "description": "Exports `Tidy3dBaseModel` instance to .yaml, .json, or .hdf5 file"
    },
    {
      "name": "upload",
      "kind": "function",
      "signature": "upload()",
      "description": "Upload this `Job` if not already got cached results."
    }
  ],
  "group": "flex_rf.web"
}
