Client API reference¶
This page is generated from the exported sysml_studio classes and their
docstrings. New public methods appear automatically. Defaults and signatures
come from Python source, rather than a manually maintained copy.
All requests use the origin and key configured on sysml_studio.Client.
Non-2xx HTTP responses raise sysml_studio.APIError; connection and HTTP
timeout failures remain httpx exceptions. The client does not retry requests.
Public Dimmara Studio client API.
- class sysml_studio.Client(base_url, api_key=None, *, timeout=30, transport=None)[source]¶
Bases:
objectSynchronous authenticated client for a Studio application.
- Parameters:
base_url (str) – Application origin, such as
https://studio.example. Paths, queries and credentials in the URL are rejected. Plain HTTP is allowed only for loopback hosts.api_key (str | None) – Bearer key; defaults to
SYSML_STUDIO_API_KEY.timeout (float | httpx.Timeout) – Per-request HTTP timeout in seconds. Job polling uses its own deadline; see
wait().transport (httpx.BaseTransport | None) – Optional custom HTTP transport, primarily for tests. Normal network requests verify TLS.
- Raises:
ValueError – Invalid application origin or missing/invalid API key.
Use a
with Client(...) as studio:block or callclose()to release connections. HTTP errors raiseAPIError; transport failures remainhttpxexceptions. Redirects and automatic retries are disabled. The server enforces entitlements, authorization, API-key scopes and quotas.- cancel_job(job_id)[source]¶
Request cancellation of a queued or running job.
- Parameters:
job_id (str) – Job UUID.
- Returns:
Server cancellation response. Poll
get_job()for the terminal status; a running worker may take time to stop.- Return type:
dict
- check_access()[source]¶
Check this key’s current server-verified entitlement and limits.
- Returns:
Access, plan and quota information supplied by Studio.
- Return type:
dict
- Raises:
APIError – Key, entitlement or required agreements are not accepted.
- contract()[source]¶
Read the server’s versioned modeling contract and capabilities.
- Returns:
API/engine versions, project/job schemas and supported job states.
- Return type:
dict
- create_space(name, *, description='', visibility='private')[source]¶
Create a project space using the caller’s authorized sharing scope.
- Parameters:
name (str) – Space display name.
description (str) – Optional descriptive text.
visibility (str) –
private,projectororganization; organization visibility requires an active seat.
- Returns:
New project-space record, including its UUID.
- Return type:
dict
- delete_model(model_id)[source]¶
Delete a model the caller is permitted to delete.
- Parameters:
model_id (str) – Model UUID.
- Returns:
The server accepted the deletion.
- Return type:
None
- Raises:
APIError – Permission, dependency or other server checks reject it.
- dependents(model_id)[source]¶
List visible saved models that depend on this model.
- Parameters:
model_id (str) – Referenced model UUID.
- Returns:
Server-filtered dependency impact information.
- Return type:
list[dict]
- download_results(job_id, output_dir)[source]¶
Download every advertised artifact and write a client job manifest.
- Parameters:
job_id (str) – Successful job UUID.
output_dir (str | Path) – Destination directory, created if needed. Use a fresh directory for each run or download attempt.
- Returns:
Absolute paths to
job.jsonand downloaded artifacts.- Return type:
list[Path]
- Raises:
Archives are saved without extraction. If a transfer fails, completed files and the manifest remain; only the incomplete file is removed. Network failures propagate as
httpxexceptions. Retry into a new directory to avoid overwriting the completed files.
- get_component(component_id)[source]¶
Fetch a visible catalog component and its generated model source.
- Parameters:
component_id (str) – Catalog component UUID.
- Returns:
Definition,
source,model_specand edit permission.- Return type:
dict
- get_connected_model(model_id, *, version=None)[source]¶
Resolve a saved revision and its pinned dependencies for local execution.
Requires sysml2py. Typed Python also requires the reference compiler.
- Parameters:
model_id (str) – Root model UUID.
version (int | None) – Root revision; None selects the latest.
- Returns:
Executable local model whose dependency revisions were authorized and resolved by Studio.
- Return type:
- Raises:
ImportError – The local engine is not installed.
ValueError – Source violates the supported execution profile.
RuntimeError – Required reference compiler resources are unavailable.
- get_graph(model_id, *, version=None)[source]¶
Resolve authorized sources into local executable graph data.
- Parameters:
model_id (str) – Root model UUID.
version (int | None) – Root revision; None selects the latest.
- Returns:
Graph with instances, attributes, connections and behaviors.
- Return type:
dict
Uses
get_connected_model()and has the same local prerequisites.
- get_job(job_id)[source]¶
Fetch the current job status, progress and artifact metadata.
- Parameters:
job_id (str) – Job UUID.
- Returns:
Fresh snapshot; previously returned snapshots do not update.
- Return type:
- instantiate_component(component_id)[source]¶
Create a saved model from a visible component template.
- Parameters:
component_id (str) – Catalog component UUID.
- Returns:
Newly saved model snapshot.
- Return type:
- list_components(*, search='', offset=0)[source]¶
Fetch one page of visible catalog components.
- Parameters:
search (str) – Server-side text filter.
offset (int) – Zero-based page offset, initially zero.
- Returns:
itemsandnext_offset; None means no further page.- Return type:
dict
- list_models()[source]¶
List visible model summaries, up to the server’s current limit.
- Returns:
Summaries. Use
get_model()to retrieve source and aModelsnapshot. No pagination is performed by the SDK.- Return type:
list[dict]
- list_spaces()[source]¶
List project spaces available to this caller.
- Returns:
Owned and shared project spaces, subject to server limits.
- Return type:
list[dict]
- resolve_model(model_id, *, version=None)[source]¶
Fetch an authorized root revision and its pinned dependencies.
- Parameters:
model_id (str) – Root model UUID.
version (int | None) – Root revision; None selects the latest.
- Returns:
Resolved bundle with
documentsin dependency order and the root last, plus provenance. No local engine is required.- Return type:
dict
- Raises:
APIError – A revision is missing, inaccessible or cannot be resolved.
- results(job_id)[source]¶
Download numerical simulation data as versioned JSON.
- Parameters:
job_id (str) – Successful simulation job UUID.
- Returns:
sysml2py.results.v1data withcolumns,units,rowsandmetadata. The first column is time.- Return type:
dict
- Raises:
ValueError – The result schema is unsupported by this client.
APIError – The result artifact is not available to the caller.
- revisions(model_id)[source]¶
List saved revisions without downloading each source.
- Parameters:
model_id (str) – Model UUID.
- Returns:
Revision number, creation time and language, newest first.
- Return type:
list[dict]
- save_component(definition, *, component_id=None)[source]¶
Create or update a catalog component using the server’s schema.
- Parameters:
definition (dict) – ComponentInput fields. For updates include the existing
versionto detect conflicting edits.component_id (str | None) – Existing component UUID, or None to create.
- Returns:
Saved component response.
- Return type:
dict
- Raises:
APIError – Invalid definition, denied access or stale revision (409).
- save_model(model, *, source=None, dependencies=None)[source]¶
Create a revision using optimistic concurrency control.
- Parameters:
model (Model) – Snapshot whose version is the expected current revision. Its name, language and sharing settings are preserved.
source (str | None) – Replacement source; None keeps the old source.
dependencies (Iterable[dict] | None) – Replacement revision pins; None preserves them, while an empty iterable removes them.
- Returns:
New saved snapshot; the input object is unchanged.
- Return type:
- Raises:
APIError – HTTP 409 if another save made this revision stale.
Update an item’s server-enforced sharing scope.
- Parameters:
kind (str) –
projects,jobsorcomponents.item_id (str) – UUID of the item to update.
visibility (str) – Authorized scope, for example
private,organizationorprojectfor a project space.project_space_id (str | None) – Space UUID required by project scope.
- Returns:
Updated sharing response.
- Return type:
dict
- Raises:
ValueError – Unsupported item kind.
APIError – The caller cannot assign the requested scope.
- simulate(model_id, *, initial_time=0, end_time=10, step_size=1, inputs=None, initial_values=None, events=None, time_attribute=None, step_attribute=None, version=None, idempotency_key=None, output_dir=None, timeout=300)[source]¶
Run a saved connected model remotely and optionally download artifacts.
- Parameters:
model_id (str) – Saved root model UUID.
initial_time (float) – Initial simulation time in seconds.
end_time (float) – Final time in seconds, not before initial_time.
step_size (float) – Positive step duration in seconds.
inputs (dict | None) – Fully qualified undriven input paths mapped to numbers, booleans,
{value, unit}quantities, or{samples: [{time, value}], unit}sampled signals.initial_values (dict | None) – Permitted stored-attribute overrides, as scalars or quantities. Connected/bound targets are rejected.
events (list[dict] | None) – Scheduled events with
timein seconds,targetstate-machine path andeventname.time_attribute (str | None) – Declared duration input populated with the simulation clock, in the model’s unit.
step_attribute (str | None) – Declared duration input populated with the actual step duration, including the final partial step.
version (int | None) – Root revision; None selects the latest saved revision. Dependency revisions remain pinned.
idempotency_key (str | None) – Stable key for retrying the same job.
output_dir (str | Path | None) – Download destination, or None to leave artifacts on the server. Existing files are not replaced.
timeout (float) – Waiting deadline in seconds, passed to
wait(). This does not include the optional artifact download time.
- Returns:
Successful job with simulation metadata.
results()fetches numerical rows;download_results()fetches all files.- Return type:
- Raises:
For long-running work use
start_job(), retain its ID, then callwait()separately. No local compiler or engine is required.
- space_items(space_id)[source]¶
List the visible models, jobs and components assigned to a space.
- Parameters:
space_id (str) – Project-space UUID.
- Returns:
Server-grouped items for the requested project space.
- Return type:
dict
- start_job(model_id, kind, *, idempotency_key=None, **options)[source]¶
Submit work and return immediately with its job ID.
- Parameters:
model_id (str) – Saved model UUID.
kind (str) –
compilefor reference validation,validatefor execution-profile validation,translateorsimulate.idempotency_key (str | None) – Stable retry key for the same request.
**options – Job options validated by the server.
versionpins the root revision. Simulation accepts the inputs and clocks documented bysimulate(); translation acceptsexecutable=Truefor executable Python interchange.
- Returns:
Initial snapshot. Retain its ID for polling and cancellation.
- Return type:
- Raises:
ValueError – Unsupported job kind or invalid model UUID.
APIError – Quota, permissions or job options are rejected.
- submit_model(name, source, *, language='sysml', dependencies=(), idempotency_key=None)[source]¶
Save a new model without starting validation or simulation.
- Parameters:
name (str) – Model display name.
source (str) – SysML text or supported declarative Python source.
language (str) –
"sysml"or"python".dependencies (Iterable[dict]) – Pins with
project_idUUID and integerversionfor each linked model.idempotency_key (str | None) – Stable key for retrying the same submission after an ambiguous network failure.
- Returns:
Saved initial revision. Saving does not certify validity.
- Return type:
- Raises:
ValueError – Language is unsupported.
APIError – Submission is rejected by the server.
- submit_object(name, model, *, dependencies=(), idempotency_key=None)[source]¶
Serialize a local engine object and save it as SysML.
- Parameters:
name (str) – Saved model display name.
model (object) – A
sysml2py.Model,SysMLDocumentorConnectedModel. Connected models embed their source bundle.dependencies (Iterable[dict]) – External revision pins to attach.
idempotency_key (str | None) – Stable key for the same submission.
- Returns:
Saved Studio snapshot.
- Return type:
- Raises:
ImportError – The optional local engine is not installed.
ValueError – Object or arbitrary runtime callbacks cannot be serialized.
- validate(model_id, *, version=None, idempotency_key=None, **wait_options)[source]¶
Submit reference-compiler syntax/semantic validation and wait.
- Parameters:
model_id (str) – Saved model UUID.
version (int | None) – Root revision; None selects the latest.
idempotency_key (str | None) – Stable key for the validation request.
**wait_options –
timeoutandpoll_intervalforwait().
- Returns:
Completed compiler job. Check its result report for validity.
- Return type:
- Raises:
JobFailed – Compiler work failed or was cancelled.
TimeoutError – Waiting expired; the job remains available by ID.
Python is checked as supported interchange, without executing source. Compiler resources live on the worker; no local engine is required. Reference validity and executable-profile support are separate checks.
- validate_execution(model_id, *, version=None, idempotency_key=None, **wait_options)[source]¶
Submit execution-profile validation and wait for its report.
- Parameters:
model_id (str) – Saved model UUID.
version (int | None) – Root revision; None selects the latest.
idempotency_key (str | None) – Stable key for the validation request.
**wait_options –
timeoutandpoll_intervalpassed towait(), in seconds.
- Returns:
Completed validation job. Inspect
job.result["valid"]andjob.result["diagnostics"]; successful processing can report an invalid model. Typed Python additionally requires reference checks.- Return type:
- Raises:
JobFailed – The job failed or was cancelled.
TimeoutError – Waiting expired; the remote job continues.
- wait(job_id, *, timeout=300, poll_interval=2)[source]¶
Poll until a job succeeds, fails, is cancelled or reaches a deadline.
- Parameters:
job_id (str) – Job UUID retained from
start_job().timeout (float) – Positive finite waiting deadline in seconds.
poll_interval (float) – Positive finite delay between polls, in seconds.
- Returns:
Snapshot with
status == "succeeded".- Return type:
- Raises:
JobFailed – The job failed or was cancelled.
TimeoutError – Deadline expired. The remote job remains running; retrieve it later with the same ID or explicitly cancel it.
ValueError – Timing arguments are not finite and positive.
Each poll’s HTTP timeout is bounded by 30 seconds and the remaining deadline. HTTP failures propagate immediately, without automatic retry.
- class sysml_studio.Model(id, name, source, language, version, visibility='private', project_space_id=None, dependencies=())[source]¶
Bases:
objectAn immutable snapshot of a saved Studio model revision.
- Variables:
id (str) – Model UUID.
name (str) – Display name.
source (str) – Saved SysML or declarative Python source.
language (str) –
"sysml"or"python".version (int) – Revision used for optimistic saves and pinned jobs.
visibility (str) – Current sharing scope.
project_space_id (str | None) – Owning project space, if assigned.
dependencies (tuple) – Revision pins containing
project_idandversion. Referenced dictionaries are not deeply immutable.
- Parameters:
id (str)
name (str)
source (str)
language (str)
version (int)
visibility (str)
project_space_id (str | None)
dependencies (tuple)
- classmethod from_response(data)[source]¶
Construct a snapshot from a Studio response, ignoring extra fields.
- Parameters:
data (dict) – Response containing the required model fields.
- Returns:
Snapshot with dependency pins stored as a tuple.
- Return type:
- to_connected_model()[source]¶
Build the current execution profile for a standalone saved model.
Linked sources need Client.get_connected_model(id, version=version), which retrieves their exact authorized dependency revisions.
- Returns:
Resolved executable model.
- Return type:
- Raises:
ValueError – The model has external dependencies or invalid source.
ImportError – The optional local engine is not installed.
RuntimeError – Required reference compiler resources are unavailable.
- to_document()[source]¶
Convert this source to a local SysML document without executing it.
- Returns:
Text interchange document.
- Return type:
sysml2py.translation.SysMLDocument
- Raises:
ImportError – The optional
sysml2pyengine is not installed.ValueError – Python is outside the supported authoring subset or generated SysML fails validation.
RuntimeError – Typed Python needs an unavailable reference compiler.
This method does not fetch dependencies. Use
Client.get_connected_model()for a linked source bundle.
- to_model()[source]¶
Convert to the legacy numeric assignment model.
- Returns:
Legacy model supporting the older assignment subset.
- Return type:
sysml2py.Model
Use
to_connected_model()for current actions, calculations, units, state machines and requirements. Requires the optional local engine; unsupported constructs raiseValueError.
- class sysml_studio.Job(id, status, result=None, error=None, artifacts=(), progress=0, cancel_requested=False, provenance=())[source]¶
Bases:
objectAn immutable snapshot of a remote job, refreshed with Client.get_job.
- Variables:
id (str) – Job UUID.
status (str) –
queued,running,succeeded,failedorcancelled.result (dict | None) – Job-kind-specific report or simulation metadata. Fetch numerical rows using
Client.results().error (str | None) – Worker failure detail when available.
artifacts (tuple) – Advertised artifact metadata, including each name.
progress (int) – Reported completion percentage.
cancel_requested (bool) – Whether cancellation has been requested.
provenance (tuple) – Root and dependency revisions used by the job.
- Parameters:
id (str)
status (str)
result (dict | None)
error (str | None)
artifacts (tuple)
progress (int)
cancel_requested (bool)
provenance (tuple)
- exception sysml_studio.APIError(status_code, detail, retry_after=None, request_id=None)[source]¶
Bases:
RuntimeErrorAn HTTP response outside the 2xx range, including redirects.
- Parameters:
status_code (int) – HTTP status returned by Studio.
detail (object) – Server error detail, or
"Request rejected".retry_after (str | None) – Raw
Retry-Afterheader, when supplied.request_id (str | None) – Server request identifier for troubleshooting.
- Variables:
status_code (int) – HTTP status, for example 409 for a stale revision.
detail (object) – Error detail returned by the server.
retry_after (str | None) – Retry hint; the client does not retry itself.
request_id (str | None) – Correlation identifier, when available.
Connection failures and HTTP timeouts remain
httpxexceptions.
- exception sysml_studio.JobFailed[source]¶
Bases:
RuntimeErrorA waited job failed or was cancelled, or results are not yet available.
The message contains the worker’s error when available. Retain the job ID from
Client.start_job()to inspect or resume a detached workflow.