Core

This page lists the four top-level jcmsuite functions and the editor function. See the linked workflow pages for examples.

Solve

jcmsuite.solve(project_file, *, keys=None, resultbag=None, recompute=False, max_retries=0, on_error='raise', context=None, backend=None, working_dir=None, jcmt_pattern=None, temporary=False, dispatch='wait', wait_break_when='all', wait_timeout=None, wait_on_timeout='raise', wait_progress=False, wait_progress_label=None, quiet=False, mode='solve', asynchronous=False)[source]

Solve one project or one ordered project bundle.

Parameters:
  • project_file (str | Path | Sequence[str | Path]) – project file (.jcmp or .jcm) or one ordered project bundle. You can give an ordered project bundle as a list or tuple of project files. JCMsuite runs the projects in the given order. If keys contains batched project keys, JCMsuite runs the complete bundle for each set of project keys. JCMsuite first resolves a relative path from the Python file that calls solve(…). If this is not possible, it resolves the path from the current working directory.

  • keys (Mapping[str, object] | Sequence[Mapping[str, object]] | None, optional) – One set of project keys, batched project keys, or None if the project does not use project keys.

  • resultbag (Resultbag | None, optional) – Resultbag in which to store and find results. An ordered project bundle is one Resultbag entry for each set of project keys.

  • recompute (bool, optional) – If False, reuse matching Resultbag entries. If True, run the solve again.

  • max_retries (int, optional) – Number of times to try a failed solve again. Use 0 to disable retries. For a daemon-backed ordered project bundle, an execution failure retries the complete bundle. A timeout does not resubmit the bundle. This option requires dispatch=”wait”.

  • on_error ({"raise", "collect"}, optional) – Error policy for batched project keys. “raise” stops at the first failed entry. “collect” stores failures as BatchSolveFailure records and continues with the remaining entries.

  • context (SolverContext | None, optional) – JCMsuite settings to use. If omitted, use the active context or the default context.

  • backend (BackendMode | None, optional) – Execution method to use. If omitted, use the method from context.

  • working_dir (WorkingDirInput, optional) – Directory in which to run each solve. For batched project keys, give one directory for each set of project keys. For a batch with one entry, one directory is also valid. For an ordered project bundle, one directory contains all project working directories. JCMsuite preserves the relative project paths and copies shared project support files into this directory. If you set working_dir, JCMsuite uses it even if temporary=True. For a daemon-backed bundle batch, omitted directories create separate temporary roots for uncached entries. Explicit live roots must not overlap. If several entries execute, their roots must not contain the source project files.

  • jcmt_pattern (str | None, optional) – JCMT pattern for project support files. The solve first tries name.<suffix>.jcmt or name.<suffix>.jcm, then uses the unsuffixed file.

  • temporary (bool, optional) – If True and working_dir is omitted, create a temporary working directory for each solve entry. If the context defines a temporary directory root, the solve creates the directories below that root. If False and working_dir is omitted, the solve runs in the project directory, except for daemon-backed bundle batches, which use separate temporary roots for uncached entries.

  • dispatch ({"wait", "submit"}, optional) – Daemon return behavior. “wait” waits for the solve and returns its result. “submit” returns a submission before the solve is complete. For an ordered project bundle, both options submit the complete bundle as one daemon job. “submit” returns its Submission after all projects are prepared and submitted. A subsequent wait() collects the bundle results without submitting further projects.

  • wait_break_when ({"all", "any"}, optional) – Condition that ends a daemon wait. “all” waits for all requested solves. “any” returns after the first requested solve finishes. Daemon-backed ordered bundles and bundle batches require “all”.

  • wait_timeout (float | None, optional) – Maximum number of seconds to wait for daemon results. If omitted, wait without a time limit.

  • wait_on_timeout ({"raise", "return"}, optional) – Action at the daemon time limit. “raise” raises an error. “return” returns the results that are available. Daemon-backed ordered bundles and bundle batches require “raise”.

  • wait_progress (bool, optional) – If True, show progress while waiting for a batch.

  • wait_progress_label (str | None, optional) – Text to show with the progress display. If omitted, use “daemon.wait” for a daemon wait or “solve(batch)” for a local batch.

  • quiet (bool, optional) – If True, do not show output from a local solve.

  • mode (Literal["solve", "postprocess"], optional) – Defaults to "solve"; use "postprocess" to run only declared postprocesses with accessible saved fieldbags. Resultbag is not supported in postprocess mode.

  • asynchronous (bool, optional) – If True, return a value that you must use with await.

Returns:

One project with one set of project keys returns SolveResult. One project with batched project keys returns BatchSolveResult. An ordered project bundle returns BundledSolveResult or BundledBatchSolveResult. If dispatch=”submit”, the function returns the corresponding submission. If asynchronous=True, the function returns a value that you must use with await.

Return type:

SolveResult | BatchSolveResult | BundledSolveResult | BundledBatchSolveResult | SolveSubmission | BatchSolveSubmission | BundledSolveSubmission | BundledBatchSolveSubmission | Coroutine[…]

Raises:
  • RuntimeError – If asynchronous code calls the function without asynchronous=True.

  • SourceMappingError – If a template or JCMsuite input error identifies a source position.

  • SolveExecutionError – If JCMsuite reports a solve failure. The call trims internal traceback frames and preserves the solver’s diagnostic details.

  • InvalidConfigurationError – If the project input or option combination is not valid.

Geo

jcmsuite.geo(project_dir='.', *, keys=None, working_dir=None, jcmt_pattern=None, show=False, show_duration=float('inf'), context=None, asynchronous=False)[source]

Create the mesh for a project with JCMgeo.

Parameters:
  • project_dir (str | Path, optional) – project directory that contains layout.jcm or layout.jcmt.

  • keys (Mapping[str, object] | None, optional) – project keys for .jcmt input files.

  • working_dir (str | Path | None, optional) – Directory in which JCMgeo creates the mesh. If omitted, use project_dir.

  • jcmt_pattern (str | None, optional) – JCMT pattern that selects layout.<suffix>.jcm or layout.<suffix>.jcmt before the unsuffixed file.

  • show (bool, optional) – If True, show the generated mesh with JCMgeo.

  • show_duration (float, optional) – Number of seconds to show the mesh if show=True. Use float(“inf”) to keep the mesh window open.

  • context (SolverContext | None, optional) – JCMsuite settings to use. If omitted, use the active context or the default context.

  • asynchronous (bool, optional) – If True, return a value that you must use with await.

Returns:

None after the mesh is created. If asynchronous is True, returns a coroutine that creates the mesh.

Return type:

None | Coroutine[object, object, None]

Raises:
  • InvalidConfigurationError – If a project directory or working directory is not valid.

  • ConfigMappingError – If JCMgeo reports an error at a position in an input file.

  • RuntimeContextError – If JCMgeo is not available.

  • RuntimeError – If JCMgeo fails. This error also occurs if asynchronous code calls the function without asynchronous=True.

  • TypeError – If show is not a Boolean value or show_duration is not a number.

  • ValueError – If show=True and show_duration is not positive.

View

jcmsuite.view(jcm_file, *, context=None, asynchronous=False)[source]

Open a JCMsuite grid or fieldbag file in JCMview.

Parameters:
  • jcm_file (str | Path) – Path to an existing .jcm grid or fieldbag file.

  • context (SolverContext | None, optional) – JCMsuite settings to use. If omitted, use the active context or the default context.

  • asynchronous (bool, optional) – If True, return a value that you must use with await.

Returns:

None after JCMview starts. If asynchronous is True, returns a coroutine that starts JCMview.

Return type:

None | Coroutine[object, object, None]

Raises:

Editing in the editor

jcmsuite.editing.edit(file_name=None, *, line=1, col=1, set_status=None, hint='', context=None, asynchronous=False)[source]

Open a project file or template in JCMedit.

Parameters:
  • file_name (str | Path | None, optional) – File to open. If omitted, open JCMedit without a selected file.

  • line (int, optional) – One-based line number to select.

  • col (int, optional) – One-based column number to select.

  • set_status ({"on", "off"} | None, optional) – Use “on” to enable automatic editor windows. Use “off” to disable them.

  • hint (str, optional) – Text to send to the editor with the selected source position.

  • context (SolverContext | None, optional) – JCMsuite settings to use. If omitted, use the active context or the default context.

  • asynchronous (bool, optional) – If True, return a value that you must use with await.

Returns:

None after JCMedit starts or when automatic editor windows are disabled. If asynchronous is True, returns a coroutine that performs the operation.

Return type:

None | Coroutine[object, object, None]

Raises:
  • InvalidConfigurationError – If file_name does not identify an existing file.

  • RuntimeContextError – If the JCMedit service cannot start.

  • RuntimeError – If asynchronous code calls the function without asynchronous=True.

  • ValueError – If line, col, or set_status is not valid.

Info

jcmsuite.info(*, context=None, print=True, verbose=False)[source]

Return installation, system, and license information.

Parameters:
  • context (SolverContext | None, optional) – JCMsuite settings to use. If omitted, use the active context or the default context.

  • print (bool, optional) – If True, show the information in the terminal.

  • verbose (bool, optional) – If True, also show the interface build time and Git commit identifier.

Returns:

Installation, computer, interface, and license information.

Return type:

JCMInfoDetails

Raises:
  • RuntimeContextError – If JCMsuite is not configured or JCMsolve is not available.

  • RuntimeError – If called from asynchronous code before context startup is complete.

Related workflows: