DSClient
The main client interface for all DAPI functionality. DSClient provides organized access to DesignSafe resources through the Tapis V3 API.
Main client for interacting with DesignSafe resources via Tapis V3 using dapi.
The DSClient provides a high-level interface for working with DesignSafe resources through the Tapis V3 API. It handles authentication and provides organized access to different service areas including applications, files, jobs, systems, and databases.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Pre-authenticated Tapis client instance. If provided, it will be used instead of creating a new one.
TYPE:
|
**auth_kwargs
|
Additional authentication arguments passed to auth.init() when tapis_client is not provided. See auth.init() for available options.
DEFAULT:
|
ATTRIBUTE | DESCRIPTION |
---|---|
tapis |
The underlying authenticated Tapis client instance.
TYPE:
|
apps |
Interface for application discovery and details.
TYPE:
|
files |
Interface for file operations (upload, download, list).
TYPE:
|
jobs |
Interface for job submission and monitoring.
TYPE:
|
systems |
Interface for system information and queues.
TYPE:
|
db |
Interface for database connections and queries.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TypeError
|
If tapis_client is provided but is not a Tapis instance. |
AuthenticationError
|
If authentication fails when creating a new Tapis client. |
Example
Basic usage with automatic authentication:
client = DSClient() Enter DesignSafe Username: myuser Enter DesignSafe Password: [hidden] Authentication successful.
Using explicit credentials:
client = DSClient(username="myuser", password="mypass") Authentication successful.
Using a pre-authenticated Tapis client:
tapis = Tapis(base_url="https://designsafe.tapis.io", ...) tapis.get_tokens() client = DSClient(tapis_client=tapis)
Initialize the DSClient with authentication and service interfaces.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Pre-authenticated Tapis client instance. If provided, it will be used instead of creating a new one.
TYPE:
|
**auth_kwargs
|
Additional authentication arguments passed to auth.init() when tapis_client is not provided. Common arguments include: - username (str): DesignSafe username - password (str): DesignSafe password - base_url (str): Tapis base URL - env_file (str): Path to .env file with credentials
DEFAULT:
|
RAISES | DESCRIPTION |
---|---|
TypeError
|
If tapis_client is provided but is not a Tapis instance. |
AuthenticationError
|
If authentication fails when creating new client. |
Source code in dapi/client.py
Accessing the Raw Tapis Client
For advanced use cases or accessing Tapis APIs not wrapped by dapi, you can get the underlying Tapis client:
from dapi import DSClient
# Initialize DSClient
ds = DSClient()
# Access the raw Tapis client
tapis_client = ds.tapis
# Use raw Tapis APIs directly
raw_apps = tapis_client.apps.getApps(search="*opensees*")
systems = tapis_client.systems.getSystems()
jobs = tapis_client.jobs.getJobList()
When to Use the Raw Tapis Client
- Access Tapis APIs not yet wrapped by dapi
- Use advanced search parameters not exposed by dapi
- Implement custom functionality
- Debug or troubleshoot API calls
- Access experimental or new Tapis features
Warning
When using the raw Tapis client, you'll need to handle errors and data formatting yourself. The dapi wrapper provides error handling and user-friendly formatting.
Service Interfaces
The DSClient provides access to different DesignSafe services through specialized interface classes:
AppMethods
Interface for Tapis application discovery and details retrieval.
This class provides methods for finding and getting detailed information about Tapis applications available for job submission.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Initialize AppMethods with a Tapis client.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Source code in dapi/client.py
find
Search for Tapis apps matching a search term.
This is a convenience wrapper around apps_module.find_apps().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to find_apps().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to find_apps().
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
List[Tapis]
|
List[Tapis]: List of matching Tapis app objects. |
RAISES | DESCRIPTION |
---|---|
AppDiscoveryError
|
If the search fails or encounters an error. |
Source code in dapi/client.py
get_details
Get detailed information for a specific app ID and version.
This is a convenience wrapper around apps_module.get_app_details().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to get_app_details().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to get_app_details().
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
Optional[Tapis]
|
Optional[Tapis]: Tapis app object with full details, or None if not found. |
RAISES | DESCRIPTION |
---|---|
AppDiscoveryError
|
If the retrieval fails or encounters an error. |
Source code in dapi/client.py
FileMethods
Interface for file operations on Tapis storage systems.
This class provides methods for uploading, downloading, listing files, and translating DesignSafe-style paths to Tapis URIs.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Initialize FileMethods with a Tapis client.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Source code in dapi/client.py
translate_path_to_uri
Translate DesignSafe-style paths to Tapis URIs.
This is a convenience wrapper around files_module.get_ds_path_uri().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to get_ds_path_uri().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to get_ds_path_uri().
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The corresponding Tapis URI (e.g., tapis://system-id/path).
TYPE:
|
RAISES | DESCRIPTION |
---|---|
FileOperationError
|
If path translation fails. |
ValueError
|
If the input path format is unrecognized. |
Source code in dapi/client.py
translate_uri_to_path
Translate Tapis URIs to DesignSafe local paths.
This is a convenience wrapper around files_module.tapis_uri_to_local_path().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to tapis_uri_to_local_path().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to tapis_uri_to_local_path().
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The corresponding DesignSafe local path (e.g., /home/jupyter/MyData/path).
TYPE:
|
Example
local_path = client.files.translate_uri_to_path("tapis://designsafe.storage.default/user/data") print(local_path) # "/home/jupyter/MyData/data"
Source code in dapi/client.py
upload
Upload a local file to a Tapis storage system.
This is a convenience wrapper around files_module.upload_file().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to upload_file().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to upload_file().
DEFAULT:
|
RAISES | DESCRIPTION |
---|---|
FileOperationError
|
If the upload operation fails. |
FileNotFoundError
|
If the local file does not exist. |
Source code in dapi/client.py
download
Download a file from a Tapis storage system to local filesystem.
This is a convenience wrapper around files_module.download_file().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to download_file().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to download_file().
DEFAULT:
|
RAISES | DESCRIPTION |
---|---|
FileOperationError
|
If the download operation fails. |
Source code in dapi/client.py
list
List files and directories in a Tapis storage system path.
This is a convenience wrapper around files_module.list_files().
PARAMETER | DESCRIPTION |
---|---|
*args
|
Positional arguments passed to list_files().
DEFAULT:
|
**kwargs
|
Keyword arguments passed to list_files().
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
List[Tapis]
|
List[Tapis]: List of file/directory objects from the specified path. |
RAISES | DESCRIPTION |
---|---|
FileOperationError
|
If the listing operation fails. |
Source code in dapi/client.py
JobMethods
Interface for Tapis job submission, monitoring, and management.
This class provides methods for generating job requests, submitting jobs, monitoring job status, and managing submitted jobs.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Initialize JobMethods with a Tapis client.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Source code in dapi/client.py
generate_request
generate_request(
app_id,
input_dir_uri,
script_filename=None,
app_version=None,
job_name=None,
description=None,
tags=None,
max_minutes=None,
node_count=None,
cores_per_node=None,
memory_mb=None,
queue=None,
allocation=None,
archive_system=None,
archive_path=None,
extra_file_inputs=None,
extra_app_args=None,
extra_env_vars=None,
extra_scheduler_options=None,
script_param_names=[
"Input Script",
"Main Script",
"tclScript",
],
input_dir_param_name="Input Directory",
allocation_param_name="TACC Allocation",
)
Generate a Tapis job request dictionary based on app definition and inputs.
This method creates a properly formatted job request dictionary that can be submitted to Tapis. It automatically retrieves app details and applies user-specified overrides and extra parameters.
PARAMETER | DESCRIPTION |
---|---|
app_id
|
The ID of the Tapis application to use for the job.
TYPE:
|
input_dir_uri
|
Tapis URI to the input directory containing job files.
TYPE:
|
script_filename
|
Name of the main script file to execute. If None, no script parameter is added (suitable for apps like OpenFOAM).
TYPE:
|
app_version
|
Specific app version. If None, uses latest.
TYPE:
|
job_name
|
Custom job name. If None, auto-generates one.
TYPE:
|
description
|
Job description. If None, uses app description.
TYPE:
|
tags
|
List of tags to associate with the job.
TYPE:
|
max_minutes
|
Maximum runtime in minutes. Overrides app default.
TYPE:
|
node_count
|
Number of compute nodes. Overrides app default.
TYPE:
|
cores_per_node
|
Cores per node. Overrides app default.
TYPE:
|
memory_mb
|
Memory in MB. Overrides app default.
TYPE:
|
queue
|
Execution queue name. Overrides app default.
TYPE:
|
allocation
|
TACC allocation to charge for compute time.
TYPE:
|
archive_system
|
Archive system for job outputs. Use "designsafe" for designsafe.storage.default. If None, uses app default.
TYPE:
|
archive_path
|
Archive directory path. Can be a full path or just a directory name in MyData. If None and archive_system is "designsafe", defaults to "tapis-jobs-archive/${JobCreateDate}/${JobUUID}".
TYPE:
|
extra_file_inputs
|
Additional file inputs.
TYPE:
|
extra_app_args
|
Additional app arguments.
TYPE:
|
extra_env_vars
|
Additional environment variables.
TYPE:
|
extra_scheduler_options
|
Additional scheduler options.
TYPE:
|
script_param_names
|
Parameter names to check for script placement.
TYPE:
|
input_dir_param_name
|
Parameter name for input directory.
TYPE:
|
allocation_param_name
|
Parameter name for allocation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dict[str, Any]: Complete job request dictionary ready for submission. |
RAISES | DESCRIPTION |
---|---|
AppDiscoveryError
|
If the specified app cannot be found. |
ValueError
|
If required parameters are missing or invalid. |
JobSubmissionError
|
If job request generation fails. |
Example
job_request = client.jobs.generate_request( ... app_id="matlab-r2023a", ... input_dir_uri="tapis://designsafe.storage.default/username/input/", ... script_filename="run_analysis.m", ... max_minutes=120, ... allocation="MyProject-123" ... )
Source code in dapi/client.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
submit_request
Submit a pre-generated job request dictionary to Tapis.
This method takes a complete job request dictionary (typically generated by generate_request) and submits it to Tapis for execution.
PARAMETER | DESCRIPTION |
---|---|
job_request
|
Complete job request dictionary containing all necessary job parameters and configuration.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SubmittedJob
|
A SubmittedJob object for monitoring and managing the job.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If job_request is not a dictionary. |
JobSubmissionError
|
If the Tapis submission fails or encounters an error. |
Example
job_request = client.jobs.generate_request(...) submitted_job = client.jobs.submit_request(job_request) print(f"Job submitted with UUID: {submitted_job.uuid}")
Source code in dapi/client.py
get
Get a SubmittedJob object for managing an existing job by UUID.
PARAMETER | DESCRIPTION |
---|---|
job_uuid
|
The UUID of an existing Tapis job.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SubmittedJob
|
A SubmittedJob object for monitoring and managing the job.
TYPE:
|
Example
job = client.jobs.get("12345678-1234-1234-1234-123456789abc") status = job.status
Source code in dapi/client.py
get_status
Get the current status of a job by UUID.
PARAMETER | DESCRIPTION |
---|---|
job_uuid
|
The UUID of the job to check.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The current job status (e.g., "QUEUED", "RUNNING", "FINISHED").
TYPE:
|
RAISES | DESCRIPTION |
---|---|
JobMonitorError
|
If status retrieval fails. |
Example
status = client.jobs.get_status("12345678-1234-1234-1234-123456789abc") print(f"Job status: {status}")
Source code in dapi/client.py
get_runtime_summary
Print the runtime summary for a job by UUID.
PARAMETER | DESCRIPTION |
---|---|
job_uuid
|
The UUID of the job to analyze.
TYPE:
|
verbose
|
If True, prints detailed job history events. Defaults to False.
TYPE:
|
Example
client.jobs.get_runtime_summary("12345678-1234-1234-1234-123456789abc") Runtime Summary
QUEUED time: 00:05:30 RUNNING time: 01:23:45 TOTAL time: 01:29:15
Source code in dapi/client.py
interpret_status
Print a user-friendly interpretation of a job status.
PARAMETER | DESCRIPTION |
---|---|
final_status
|
The job status to interpret.
TYPE:
|
job_uuid
|
The job UUID for context in the message.
TYPE:
|
Example
client.jobs.interpret_status("FINISHED", "12345678-1234-1234-1234-123456789abc") Job 12345678-1234-1234-1234-123456789abc completed successfully.
Source code in dapi/client.py
SystemMethods
Interface for Tapis system information and queue management.
This class provides methods for retrieving information about Tapis execution systems and their available job queues.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Initialize SystemMethods with a Tapis client.
PARAMETER | DESCRIPTION |
---|---|
tapis_client
|
Authenticated Tapis client instance.
TYPE:
|
Source code in dapi/client.py
list_queues
List logical queues available on a Tapis execution system.
This is a convenience wrapper around systems_module.list_system_queues().
PARAMETER | DESCRIPTION |
---|---|
system_id
|
The ID of the execution system (e.g., 'frontera').
TYPE:
|
verbose
|
If True, prints detailed queue information. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[Any]
|
List[Any]: List of queue objects with queue configuration details. |
RAISES | DESCRIPTION |
---|---|
SystemInfoError
|
If the system is not found or queue retrieval fails. |
ValueError
|
If system_id is empty. |