dyff.client¶
The dyff.client package provides a Python client for interacting with the Dyff REST API.
Installation¶
Install the dyff-client
package from PyPI:
python3 -m pip install dyff-client
Configuration¶
Here are well-known API locations:
http://api.dyff.local/v0
- A self-hosted Dyff on a local machine.https://api.dyff.io/v0
- The Dyff instance hosted by UL DSRI.
Conventions¶
API functions are grouped by the resource type that they manipulate, for example, Client.datasets.create
will create a Dataset
resource. Most resources support most of the same basic operations, and the corresponding API functions will have similar signatures across different resources. The operations on Dataset
resources are defined in _Datasets
.
Many API functions accept a Request
object that holds the data to pass to the function. Refer to the dyff.schema.requests
documentation for details.
Client reference¶
- class dyff.client.Client(*, api_token: str | None = None, api_key: str | None = None, endpoint: str | None = None, verify_ssl_certificates: bool = True, insecure: bool = False, timeout: Timeout | None = None)¶
The Python client for the Dyff Platform API.
API operations are grouped by the resource type that they manipulate. For example, all operations on
Evaluation
resources are accessed likeclient.evaluations.create()
.The Python API functions may have somewhat different behavior from the corresponding API endpoints, and the Python client also adds several higher-level API functions that are implemented with multiple endpoint calls.
- Parameters:
api_token (str) – An API token to use for authentication. If not set, the token is read from the DYFF_API_TOKEN environment variable.
api_key (str) –
Deprecated alias for ‘api_token’
Deprecated since version 0.13.1: Use api_token instead
endpoint (str) – The URL where the Dyff Platform API is hosted. Defaults to the UL DSRI-hosted Dyff instance.
verify_ssl_certificates (bool) –
You can disable certificate verification for testing; you should do this only if you have also changed
endpoint
to point to a trusted local server.Deprecated since version 0.2.2: Use insecure instead
insecure (bool) – Disable certificate verification for testing. you should do this only if you have also changed
endpoint
to point to a trusted local server.
- property evaluations: _Evaluations¶
Operations on
Evaluation
entities.
- property inferenceservices: _InferenceServices¶
Operations on
InferenceService
entities.
- property inferencesessions: _InferenceSessions¶
Operations on
InferenceSession
entities.
- property insecure: bool¶
- property measurements: _Measurements¶
Operations on
Measurement
entities.
- property raw: DyffV0API¶
The “raw” API client, which can be used to send JSON requests directly.
- property safetycases: _SafetyCases¶
Operations on
SafetyCase
entities.
- property timeout: Timeout¶
- class dyff.client.InferenceSessionClient¶
A client used for making inference requests to a running
InferenceSession
.Note
Do not instantiate this class. Create an instance using
inferencesessions.client()
- infer(body: Any) Any ¶
Make an inference request.
The input and output are arbitrary JSON objects. The required format depends on the endpoint and input/output adapters specified when creating the inference client.
- Parameters:
body – A JSON object containing the inference input.
- Returns:
A JSON object containing the inference output.
API groups¶
- class dyff.client._apigroups._Datasets¶
Operations on
Dataset
entities.Note
Do not instantiate this class. Access it through the
.datasets
attribute ofClient
.- create(request: DatasetCreateRequest | dict[str, Any]) Dataset ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Dataset ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- create_arrow_dataset(dataset_directory: Path | str, *, account: str, name: str) Dataset ¶
Create a Dataset resource describing an existing Arrow dataset.
Internally, constructs a
DatasetCreateRequest
using information obtained from the Arrow dataset, then callscreate()
with the constructed request.Typical usage:
dataset = client.datasets.create_arrow_dataset(dataset_directory, ...) client.datasets.upload_arrow_dataset(dataset, dataset_directory)
- Parameters:
dataset_directory – The root directory of the Arrow dataset.
account – The account that will own the Dataset resource.
name – The name of the Dataset resource.
- Returns:
The complete Dataset resource.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- documentation(id: str) Documentation ¶
Get the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
- Returns:
The documentation associated with the entity.
- Raises:
HttpResponseError –
- downlinks(id: str) list[ArtifactURL] ¶
Get a list of signed GET URLs from which entity artifacts can be downloaded.
- Parameters:
id – The ID of the entity.
- Returns:
List of signed GET URLs.
- Raises:
HttpResponseError –
- download(id: str, destination: Path | str) None ¶
Download all of the artifact files for an entity to a local directory.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination directory. Must exist and be empty.
- Raises:
HttpResponseError –
ValueError – If arguments are invalid
- edit_documentation(id: str, edit_request: DocumentationEditRequest) Documentation ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- Returns:
The modified documentation.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, name: str | None = None) list[Dataset] ¶
Get all Datasets matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
name
- Returns:
list of
Dataset
resources satisfying the query.- Raises:
HttpResponseError –
- upload_arrow_dataset(dataset: Dataset, dataset_directory: Path | str) None ¶
Uploads the data files in an existing Arrow dataset for which a Dataset resource has already been created.
Typical usage:
dataset = client.datasets.create_arrow_dataset(dataset_directory, ...) client.datasets.upload_arrow_dataset(dataset, dataset_directory)
- Parameters:
dataset – The Dataset resource for the Arrow dataset.
dataset_directory – The root directory of the Arrow dataset.
- class dyff.client._apigroups._Evaluations¶
Operations on
Evaluation
entities.Note
Do not instantiate this class. Access it through the
.evaluations
attribute ofClient
.- create(request: EvaluationCreateRequest | dict[str, Any]) Evaluation ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Evaluation ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- documentation(id: str) Documentation ¶
Get the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
- Returns:
The documentation associated with the entity.
- Raises:
HttpResponseError –
- downlinks(id: str) list[ArtifactURL] ¶
Get a list of signed GET URLs from which entity artifacts can be downloaded.
- Parameters:
id – The ID of the entity.
- Returns:
List of signed GET URLs.
- Raises:
HttpResponseError –
- download(id: str, destination: Path | str) None ¶
Download all of the artifact files for an entity to a local directory.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination directory. Must exist and be empty.
- Raises:
HttpResponseError –
ValueError – If arguments are invalid
- edit_documentation(id: str, edit_request: DocumentationEditRequest) Documentation ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- Returns:
The modified documentation.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, dataset: str | None = None, inferenceService: str | None = None, inferenceServiceName: str | None = None, model: str | None = None, modelName: str | None = None) list[Evaluation] ¶
Get all Evaluations matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
dataset
inferenceService – Queries the
.inferenceSession.inferenceService.id
nested field.inferenceServiceName – Queries the
.inferenceSession.inferenceService.name
nested field.model – Queries the
.inferenceSession.inferenceService.model.id
nested field.modelName – Queries the
.inferenceSession.inferenceService.model.name
nested field.
- Returns:
list of
Evaluation
resources satisfying the query.- Raises:
HttpResponseError –
- class dyff.client._apigroups._InferenceServices¶
Operations on
InferenceService
entities.Note
Do not instantiate this class. Access it through the
.inferenceservices
attribute ofClient
.- create(request: InferenceServiceCreateRequest | dict[str, Any]) InferenceService ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) InferenceService ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- documentation(id: str) Documentation ¶
Get the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
- Returns:
The documentation associated with the entity.
- Raises:
HttpResponseError –
- edit_documentation(id: str, edit_request: DocumentationEditRequest) Documentation ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- Returns:
The modified documentation.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, name: str | None = None, model: str | None = None, modelName: str | None = None) list[InferenceService] ¶
Get all InferenceServices matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
name
model – Queries the
.model.id
nested field.modelName – Queries the
model.name
nested field.
- Returns:
list of
InferenceService
resources satisfying the query.- Raises:
HttpResponseError –
- class dyff.client._apigroups._InferenceSessions¶
Operations on
Inferencesession
entities.Note
Do not instantiate this class. Access it through the
.inferencesessions
attribute ofClient
.- create(request: InferenceSessionCreateRequest | dict[str, Any]) InferenceSession ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) InferenceSession ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- client(session_id: str, token: str, *, interface: InferenceInterface | None = None, endpoint: str | None = None, input_adapter: Adapter | None = None, output_adapter: Adapter | None = None) InferenceSessionClient ¶
Create an InferenceSessionClient that interacts with the given inference session. The token should be one returned either from
Client.inferencesessions.create()
or fromClient.inferencesessions.token(session_id)
.The inference endpoint in the session must also be specified, either directly through the
endpoint
argument or by specifying aninterface
. Specifyinginterface
will also use the input and output adapters from the interface. You can also specify these separately in theinput_adapter
andoutput_adapter
. The non-interface
arguments override the corresponding values ininterface
if both are specified.- Parameters:
session_id – The inference session to connect to
token – An access token with permission to run inference against the session.
interface – The interface to the session. Either
interface
orendpoint
must be specified.endpoint – The inference endpoint in the session to call. Either
endpoint
orinterface
must be specified.input_adapter – Optional input adapter, applied to the input before sending it to the session. Will override the input adapter from
interface
if both are specified.output_adapter – Optional output adapter, applied to the output of the session before returning to the client. Will override the output adapter from
interface
if both are specified.
- Returns:
An
InferenceSessionClient
that makes inference calls to the specified session.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, name: str | None = None, inferenceService: str | None = None, inferenceServiceName: str | None = None, model: str | None = None, modelName: str | None = None) list[InferenceSession] ¶
Get all InferenceSessions matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
name
inferenceService – Queries the
.inferenceService.id
nested field.inferenceServiceName – Queries the
.inferenceService.name
nested field.model – Queries the
.inferenceService.model.id
nested field.modelName – Queries the
.inferenceService.model.name
nested field.
- Returns:
list of
InferenceSession
resources satisfying the query.- Raises:
HttpResponseError –
- ready(session_id: str) bool ¶
Return True if the session is ready to receive inference input.
The readiness probe is expected to fail with status codes 404 or 503, as these will occur at times during normal session start-up. The
ready()
method returns False in these cases. Any other status codes will raise anHttpResponseError
.- Parameters:
session_id (str) – The ID of the session.
- Raises:
HttpResponseError –
- terminate(session_id: str) Status ¶
Terminate a session.
- Parameters:
session_id – The inference session key
- Returns:
The resulting status of the entity
- Raises:
HttpResponseError –
- token(session_id: str, *, expires: datetime | None = None) str ¶
Create a session token.
The session token is a short-lived token that allows the bearer to make inferences with the session (via an
InferenceSessionClient
) and to callready()
,get()
, andterminate()
on the session.- Parameters:
session_id (str) – The ID of the session.
expires (Optional[datetime]) – The expiration time of the token. Must be < the expiration time of the session. Default: expiration time of the session.
- Raises:
HttpResponseError –
- class dyff.client._apigroups._Measurements¶
Operations on
Measurement
entities.Note
Do not instantiate this class. Access it through the
.measurements
attribute ofClient
.- create(request: AnalysisCreateRequest | dict[str, Any]) Measurement ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Measurement ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- downlinks(id: str) list[ArtifactURL] ¶
Get a list of signed GET URLs from which entity artifacts can be downloaded.
- Parameters:
id – The ID of the entity.
- Returns:
List of signed GET URLs.
- Raises:
HttpResponseError –
- download(id: str, destination: Path | str) None ¶
Download all of the artifact files for an entity to a local directory.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination directory. Must exist and be empty.
- Raises:
HttpResponseError –
ValueError – If arguments are invalid
- download_logs(id, destination: Path | str) None ¶
Download the logs file from an entity.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination file. Must not exist, and its parent directory must exist.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- logs(id: str) Iterable[str] ¶
Stream the logs from an entity as a sequence of lines.
- Parameters:
id – The ID of the entity.
- Returns:
An Iterable over the lines in the logs file. The response is streamed, and may time out if it is not consumed quickly enough.
- Raises:
HttpResponseError –
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, method: str | None = None, methodName: str | None = None, dataset: str | None = None, evaluation: str | None = None, inferenceService: str | None = None, model: str | None = None, inputs: list[str] | None = None) list[Measurement] ¶
Get all Measurement entities matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
method – Queries the
.method.id
nested field.methodName – Queries the
.method.name
nested field.dataset – Queries the
.scope.dataset
nested field.evaluation – Queries the
.scope.evaluation
nested field.inferenceService – Queries the
.scope.inferenceService
nested field.model – Queries the
.scope.model
nested field.inputs – List of entity IDs. Matches Measurements that took any of these entities as inputs.
- Returns:
Entities matching the query
- Raises:
HttpResponseError –
- class dyff.client._apigroups._Methods¶
Operations on
Method
entities.Note
Do not instantiate this class. Access it through the
.analyses
attribute ofClient
.- create(request: MethodCreateRequest | dict[str, Any]) Method ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Method ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- documentation(id: str) Documentation ¶
Get the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
- Returns:
The documentation associated with the entity.
- Raises:
HttpResponseError –
- download_logs(id, destination: Path | str) None ¶
Download the logs file from an entity.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination file. Must not exist, and its parent directory must exist.
- Raises:
HttpResponseError –
- edit_documentation(id: str, edit_request: DocumentationEditRequest) Documentation ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- Returns:
The modified documentation.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- logs(id: str) Iterable[str] ¶
Stream the logs from an entity as a sequence of lines.
- Parameters:
id – The ID of the entity.
- Returns:
An Iterable over the lines in the logs file. The response is streamed, and may time out if it is not consumed quickly enough.
- Raises:
HttpResponseError –
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, name: str | None = None, outputKind: str | None = None, output_kind: str | None = None) list[Method] ¶
Get all Method entities matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
name
outputKind – Queries the
.output.kind
nested field.output_kind –
Deprecated alias for
outputKind
Deprecated since version 0.15.2: Use
outputKind
instead.
- Returns:
list of Method entities matching query
- Raises:
HttpResponseError –
- class dyff.client._apigroups._Models¶
Operations on
Model
entities.Note
Do not instantiate this class. Access it through the
.models
attribute ofClient
.- create(request: ModelCreateRequest | dict[str, Any]) Model ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Model ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- documentation(id: str) Documentation ¶
Get the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
- Returns:
The documentation associated with the entity.
- Raises:
HttpResponseError –
- edit_documentation(id: str, edit_request: DocumentationEditRequest) Documentation ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- Returns:
The modified documentation.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, name: str | None = None) list[Model] ¶
Get all Models matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
name
- Returns:
list of
Model
resources satisfying the query.- Raises:
HttpResponseError –
- class dyff.client._apigroups._Modules¶
Operations on
Module
entities.Note
Do not instantiate this class. Access it through the
.modules
attribute ofClient
.- create(request: ModuleCreateRequest | dict[str, Any]) Module ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Module ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- create_package(package_directory: Path | str, *, account: str, name: str) Module ¶
Create a Module resource describing a package structured as a directory tree.
Internally, constructs a
ModuleCreateRequest
using information obtained from the directory tree, then callscreate()
with the constructed request.Typical usage:
module = client.modules.create_package(package_directory, ...) client.modules.upload_package(module, package_directory)
- Parameters:
package_directory – The root directory of the package.
account – The account that will own the Module resource.
name – The name of the Module resource.
- Returns:
The complete Module resource.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- documentation(id: str) Documentation ¶
Get the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
- Returns:
The documentation associated with the entity.
- Raises:
HttpResponseError –
- downlinks(id: str) list[ArtifactURL] ¶
Get a list of signed GET URLs from which entity artifacts can be downloaded.
- Parameters:
id – The ID of the entity.
- Returns:
List of signed GET URLs.
- Raises:
HttpResponseError –
- download(id: str, destination: Path | str) None ¶
Download all of the artifact files for an entity to a local directory.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination directory. Must exist and be empty.
- Raises:
HttpResponseError –
ValueError – If arguments are invalid
- edit_documentation(id: str, edit_request: DocumentationEditRequest) Documentation ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- Returns:
The modified documentation.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, name: str | None = None) list[Module] ¶
Get all Modules matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
name
- Returns:
list of
Module
resources satisfying the query.- Raises:
HttpResponseError –
- upload_package(module: Module, package_directory: Path | str) None ¶
Uploads the files in a package directory for which a Module resource has already been created.
Typical usage:
module = client.modules.create_package(package_directory, ...) client.modules.upload_package(module, package_directory)
- Parameters:
module – The Module resource for the package.
package_directory – The root directory of the package.
- class dyff.client._apigroups._Reports¶
Operations on
Report
entities.Note
Do not instantiate this class. Access it through the
.reports
attribute ofClient
.- create(request: ReportCreateRequest | dict[str, Any]) Report ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) Report ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- downlinks(id: str) list[ArtifactURL] ¶
Get a list of signed GET URLs from which entity artifacts can be downloaded.
- Parameters:
id – The ID of the entity.
- Returns:
List of signed GET URLs.
- Raises:
HttpResponseError –
- download(id: str, destination: Path | str) None ¶
Download all of the artifact files for an entity to a local directory.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination directory. Must exist and be empty.
- Raises:
HttpResponseError –
ValueError – If arguments are invalid
- download_logs(id, destination: Path | str) None ¶
Download the logs file from an entity.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination file. Must not exist, and its parent directory must exist.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- logs(id: str) Iterable[str] ¶
Stream the logs from an entity as a sequence of lines.
- Parameters:
id – The ID of the entity.
- Returns:
An Iterable over the lines in the logs file. The response is streamed, and may time out if it is not consumed quickly enough.
- Raises:
HttpResponseError –
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, report: str | None = None, dataset: str | None = None, evaluation: str | None = None, inferenceService: str | None = None, model: str | None = None) list[Report] ¶
Get all Reports matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
report
dataset
evaluation
inferenceService
model
- Returns:
list of
Report
resources satisfying the query.- Raises:
HttpResponseError –
- class dyff.client._apigroups._SafetyCases¶
Operations on
SafetyCase
entities.Note
Do not instantiate this class. Access it through the
.safetycases
attribute ofClient
.- create(request: AnalysisCreateRequest | dict[str, Any]) SafetyCase ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) SafetyCase ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- downlinks(id: str) list[ArtifactURL] ¶
Get a list of signed GET URLs from which entity artifacts can be downloaded.
- Parameters:
id – The ID of the entity.
- Returns:
List of signed GET URLs.
- Raises:
HttpResponseError –
- download(id: str, destination: Path | str) None ¶
Download all of the artifact files for an entity to a local directory.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination directory. Must exist and be empty.
- Raises:
HttpResponseError –
ValueError – If arguments are invalid
- download_logs(id, destination: Path | str) None ¶
Download the logs file from an entity.
The destination path must not exist. Parent directories will be created.
- Parameters:
id – The ID of the entity.
destination – The destination file. Must not exist, and its parent directory must exist.
- Raises:
HttpResponseError –
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- logs(id: str) Iterable[str] ¶
Stream the logs from an entity as a sequence of lines.
- Parameters:
id – The ID of the entity.
- Returns:
An Iterable over the lines in the logs file. The response is streamed, and may time out if it is not consumed quickly enough.
- Raises:
HttpResponseError –
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None, method: str | None = None, methodName: str | None = None, dataset: str | None = None, evaluation: str | None = None, inferenceService: str | None = None, model: str | None = None, inputs: list[str] | None = None) list[SafetyCase] ¶
Get all SafetyCase entities matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query
id
account
status
reason
labels – Matches entities that are labeled with all of the given key-value pairs.
method – Queries the
.method.id
nested field.methodName – Queries the
.method.name
nested field.dataset – Queries the
.scope.dataset
nested field.evaluation – Queries the
.scope.evaluation
nested field.inferenceService – Queries the
.scope.inferenceService
nested field.model – Queries the
.scope.model
nested field.inputs – List of entity IDs. Matches SafetyCases that took any of these entities as inputs.
- Returns:
Entities matching the query
- Raises:
HttpResponseError –
- class dyff.client._apigroups._UseCases¶
Operations on
UseCase
entities.Note
Do not instantiate this class. Access it through the
.usecases
attribute ofClient
.- create(request: ConcernCreateRequest | dict[str, Any]) UseCase ¶
Create a new entity.
Note
This operation may incur compute costs.
- Parameters:
request – The entity create request specification.
- Returns:
A full entity spec with its .id and other system properties set
- get(id: str) UseCase ¶
Get an entity by its .id.
- Parameters:
id – The entity ID
- Returns:
The entity with the given ID.
- delete(id: str) Status ¶
Mark an entity for deletion.
- Parameters:
id – The entity ID
- Returns:
The resulting status of the entity
- edit_documentation(id: str, edit_request: DocumentationEditRequest) None ¶
Edit the documentation associated with an entity.
- Parameters:
id – The ID of the entity.
edit_request – Object containing the edits to make.
- label(id: str, labels: dict[str, str | None]) None ¶
Label the specified entity with key-value pairs (stored in the
.labels
field).Providing
None
for the value deletes the label. Key-value mappings not given inlabels
remain unchanged.See
Label
for a description of the constraints on label keys and values.- Parameters:
id – The ID of the entity to label.
labels – The label keys and values.
- publish(id: str, access: Literal['public', 'preview', 'private']) None ¶
Set the publication status of an entity in the Dyff cloud app.
Publication status affects only:
Deliberate outputs, such as the rendered HTML from a safety case
The entity spec (the information you get back from .get())
Associated documentation
Other artifacts – source code, data, logs, etc. – are never accessible to unauthenticated users.
The possible access modes are:
"public"
: Anyone can view the results"preview"
: Authorized users can view the results as theywould appear if they were public
"private"
: The results are not visible in the app
- query(*, query: str | dict[str, Any] | list[dict[str, Any]] | None = None, id: str | None = None, account: str | None = None, status: str | None = None, reason: str | None = None, labels: dict[str, str] | None = None) list[UseCase] ¶
Get all SafetyCase entities matching a query. The query is a set of equality constraints specified as key-value pairs.
- Parameters:
query –
- keyword id:
- keyword account:
- keyword status:
- keyword reason:
labels – Matches entities that are labeled with all of the given
key-value pairs. :raises HttpResponseError: