DNANexus improvements

This commit is contained in:
Timothy Kassis committed 2026-07-23 10:53:35 -07:00
1 parent 53c58974f3
commit 71917747a4
10 files changed
+171 -52

No files matched your search

+22 -8
View File
@@ -170,15 +170,25 @@ Bound broad searches with a project, folder, time range, and `limit`.
```bash
dx-app-wizard
uv run python "skills/dnanexus-integration/scripts/validate_dxapp.py" \
"./my-app/dxapp.json" --kind applet --strict
dx build "./my-app"
```
Resolve bundled helpers relative to this skill directory. From the skill root:
```bash
uv run python "scripts/validate_dxapp.py" \
"/path/to/my-app/dxapp.json" --kind applet --strict
```
Then build the source directory:
```bash
dx build "/path/to/my-app"
```
For a versioned app, use the current build form:
```bash
dx build "./my-app" --create-app
dx build "/path/to/my-app" --create-app
```
New configurations should use Ubuntu 24.04 and
@@ -218,8 +228,9 @@ dx watch "job-xxxx" --get-streams
A run of an app or applet returns a `job-...`; a run of a workflow returns an
`analysis-...`. `dxpy.DXJob.wait_on_done()` and
`dxpy.DXAnalysis.wait_on_done()` raise `DXJobFailureError` when an execution
fails. See `references/job-execution.md`.
`dxpy.DXAnalysis.wait_on_done()` can raise `DXJobFailureError` for remote
failure, termination, or local wait timeout. Re-describe remote state before
classifying it; see `references/job-execution.md`.
### Chain executions without polling
@@ -270,10 +281,13 @@ ready. Do not wrap `get_output_ref()` in `dxpy.dxlink()`.
## Bundled Helpers
The commands below assume the current directory is this skill's root. Otherwise
resolve `scripts/` relative to the loaded skill directory.
### Validate `dxapp.json`
```bash
uv run python "skills/dnanexus-integration/scripts/validate_dxapp.py" \
uv run python "scripts/validate_dxapp.py" \
"path/to/dxapp.json" --kind app --strict
```
@@ -285,7 +299,7 @@ replaces, `dx build` validation.
```bash
uv run --with "dxpy==0.410.0" \
"skills/dnanexus-integration/scripts/inspect_dxpy.py" --strict
"scripts/inspect_dxpy.py" --strict
```
This performs offline symbol and signature checks. It does not authenticate or
@@ -1,5 +1,15 @@
# App and Applet Development
## Quick Navigation
- [Model and source layout](#model)
- [Python and Bash entry points](#python-entry-point)
- [Execution environment](#execution-environment)
- [Local testing](#separate-pure-logic-from-platform-io)
- [Build and platform tests](#build)
- [Subjobs, reuse, and errors](#subjobs-and-parallelism)
- [Publish checklist](#publish-checklist)
## Model
- **Applet**: immutable executable data object in one project; best for
@@ -8,7 +18,7 @@
across projects/regions; best for maintained reusable products.
- **Job**: execution of an app or applet.
- **Entry point**: named function within an executable. `main` is used for a
normal app/appet run; other entry points can be launched as subjobs.
normal app/applet run; other entry points can be launched as subjobs.
Develop as an applet, test in a non-production project, then create and publish
an app only after reviewing code, permissions, dependencies, and regions.
@@ -201,11 +211,12 @@ Test `build_command()` locally without credentials.
## Build
Validate offline:
Validate offline from this skill's root (or resolve `scripts/` relative to the
loaded skill directory):
```bash
uv run python "skills/dnanexus-integration/scripts/validate_dxapp.py" \
"my-app/dxapp.json" --kind applet --strict
uv run python "scripts/validate_dxapp.py" \
"/path/to/my-app/dxapp.json" --kind applet --strict
```
Build an applet:
@@ -50,6 +50,19 @@ Preferred automation:
6. Verify with `dx whoami`; do not use `dx env`.
7. Remove the secret from the process environment when the operation ends.
`DX_SECURITY_CONTEXT` must contain JSON text, not a bare UI token. Its secret
value has this shape:
```json
{
"auth_token_type": "Bearer",
"auth_token": "<secret-token>"
}
```
Have the secret manager inject the complete serialized object. Do not build or
echo it in a traced shell command.
Standard user API tokens inherit the creating user's project access; they are
not independently project-scoped. Minimize the dedicated identity's project
memberships and access levels before issuing its token. If an organization
@@ -1,5 +1,17 @@
# Current `dxapp.json` Configuration
## Quick Navigation
- [Manifest purpose](#what-dxappjson-controls)
- [Applets versus apps](#applets-versus-apps)
- [Input and output specifications](#input-and-output-specifications)
- [`runSpec`](#runspec)
- [Regional resources](#regional-resources)
- [Retry and timeout policy](#retry-and-timeout-policy)
- [Dependencies](#dependencies)
- [Access requirements](#access-requirements)
- [Validation checklist](#validation-checklist)
## What `dxapp.json` Controls
`dxapp.json` is the source manifest consumed by `dx build` and
@@ -128,10 +140,10 @@ project. Do not copy a static instance list from old documentation.
}
```
Run the bundled offline check before building:
Run the bundled offline check from this skill's root before building:
```bash
uv run python "skills/dnanexus-integration/scripts/validate_dxapp.py" \
uv run python "scripts/validate_dxapp.py" \
"path/to/dxapp.json" --kind app --strict
```
@@ -1,5 +1,19 @@
# Data Operations
## Quick Navigation
- [Safety and lifecycle](#safety-model)
- [Transfer tool selection](#transfer-tool-selection)
- [Small transfers](#small-transfers-with-dx)
- [Upload Agent](#upload-agent)
- [Download Agent](#download-agent)
- [Python transfers](#python-upload-and-download)
- [Search and metadata](#search)
- [Records and folders](#records)
- [Cloning and archival](#cloning)
- [Deletion](#deletion)
- [Batch checklist](#batch-operation-checklist)
## Safety Model
DNAnexus data objects live in projects or other data containers. Before a
@@ -112,11 +126,8 @@ ua \
```
Do not run `ua --env` in captured output because it displays the active token.
`DX_API_TOKEN` and `DX_SECURITY_CONTEXT` are both secrets.
Download Agent checks `DX_API_TOKEN` and otherwise falls back to the saved
dx-toolkit configuration. `dx`, `dxpy`, and normal toolkit sessions use
`DX_SECURITY_CONTEXT`; do not assume one variable name works for every client.
Treat any Upload Agent `--auth-token` value and the toolkit
`DX_SECURITY_CONTEXT` as secrets.
Use `--do-not-resume` only when creating a deliberate second copy. Otherwise
let the agent resume interrupted uploads.
@@ -127,6 +138,10 @@ Download Agent consumes a BZIP2-compressed JSON manifest. Use the manifest
creation utility from the official `dnanexus/dxda` release and review its
resolved file set before starting egress.
Download Agent checks the secret `DX_API_TOKEN` and otherwise falls back to
`~/.dnanexus_config/environment.json`. This is a Download Agent-specific
variable; do not assume it configures Upload Agent, `dx`, or `dxpy`.
```bash
dx-download-agent download "manifest.json.bz2"
dx-download-agent progress "manifest.json.bz2"
@@ -1,11 +1,24 @@
# Jobs, Analyses, and Execution
## Quick Navigation
- [Concepts and preflight](#concepts)
- [Launch apps/applets](#launch-an-app-or-applet)
- [Launch workflows](#launch-a-workflow)
- [Lifecycle and monitoring](#lifecycle)
- [Safe waits and outputs](#wait-safely-with-dxpy)
- [Subjobs and reuse](#scattergather-with-subjobs)
- [Instances and restarts](#instance-selection)
- [Cost controls](#cost-controls)
- [Failure triage](#failure-triage)
- [Rerun and termination](#rerun)
## Concepts
- **Job** (`job-...`): execution of one app or applet entry point.
- **Analysis** (`analysis-...`): execution of a workflow and its stages.
- **Origin execution**: user-initiated root of an execution tree.
- **Master job**: app/appet run with its own temporary workspace.
- **Master job**: app/applet run with its own temporary workspace.
- **Subjob**: another entry point created with `/job/new`; normally shares its
parent job's workspace.
- **Job-based object reference (JBOR)**: dependency on a field of another
@@ -189,29 +202,35 @@ from dxpy.exceptions import DXError, DXJobFailureError
try:
job.wait_on_done(interval=10, timeout=6 * 60 * 60)
except DXJobFailureError:
failure = job.describe(
except DXJobFailureError as error:
status = job.describe(
fields={
"state": True,
"failureReason": True,
"failureMessage": True,
}
)
print(
failure.get("failureReason"),
failure.get("failureMessage"),
)
raise
state = status.get("state")
if state not in {"failed", "terminated"}:
raise TimeoutError(
f"local wait ended while remote job state is {state!r}"
) from error
reason = status.get("failureReason") or "Terminated"
message = status.get("failureMessage") or str(error)
raise RuntimeError(f"{reason}: {message}") from error
except DXError:
# Timeout or SDK/API failure; execution may still be running.
# SDK/API failure while polling; re-describe before deciding what to do.
raise
```
A local wait timeout does not terminate the remote execution. Re-describe it
before deciding whether to continue waiting or request termination.
Despite its docstring, dxpy 0.410.0 raises `DXJobFailureError` for remote
failure, termination, **and local wait timeout**. Classify the exception by
re-describing the remote state. A local timeout does not terminate the remote
execution.
`DXAnalysis.wait_on_done()` follows the same pattern and raises
`DXJobFailureError` when a stage fails.
`DXAnalysis.wait_on_done()` follows the same pattern. Treat `failed`,
`partially_failed`, and `terminated` as remote terminal outcomes; otherwise the
exception may be a local wait timeout while the analysis continues.
## Outputs
@@ -453,10 +472,11 @@ Confirm exact ID and affected execution tree:
```bash
dx terminate "job-xxxx"
dx terminate "analysis-xxxx"
```
Terminate an analysis using the appropriate analysis operation/UI after
confirming which stages and descendants are still active.
`dx terminate` accepts both job and analysis IDs. For an analysis, confirm
which stages and descendants remain active before terminating the tree.
After termination, verify final states and identify incomplete outputs or open
files that require cleanup.
@@ -1,5 +1,19 @@
# Operations and Troubleshooting
## Quick Navigation
- [Baseline and first questions](#non-secret-baseline)
- [Authentication and context](#authentication-and-context)
- [Path and object resolution](#path-and-object-resolution)
- [Upload and download problems](#upload-problems)
- [Job states and failure reasons](#job-state-problems)
- [Workflow analysis failures](#workflow-analysis-failures)
- [Nextflow and dxCompiler](#nextflow)
- [Debug access](#debug-access)
- [Service limits and cost review](#service-limits)
- [Destructive operations](#destructive-operations)
- [Support bundle](#support-bundle)
## Non-Secret Baseline
Start with:
@@ -477,7 +491,7 @@ Provide only:
- User ID (if appropriate)
- Project ID/region
- Object, job, or analysis ID
- App/appet/workflow ID and version
- App/applet/workflow ID and version
- Failure reason/message
- API request ID
- Minimal redacted log excerpt
@@ -1,5 +1,18 @@
# Python SDK (`dxpy`)
## Quick Navigation
- [Baseline and authentication](#baseline)
- [Handlers and links](#handler-model)
- [Describe and files](#describe)
- [Search](#search)
- [Projects and records](#projects-and-folders)
- [Run executables](#run-executables)
- [Wait and output](#wait-and-output)
- [Exceptions](#exceptions)
- [Low-level API bindings](#low-level-api-bindings)
- [Reliability checklist](#reliability-checklist)
## Baseline
This reference was verified against `dxpy==0.410.0` (released 2026-07-14).
@@ -17,11 +30,11 @@ For an isolated script:
uv run --with "dxpy==0.410.0" "script.py"
```
Inspect the installed API without authenticating:
Inspect the installed API without authenticating. From this skill's root:
```bash
uv run --with "dxpy==0.410.0" \
"skills/dnanexus-integration/scripts/inspect_dxpy.py" --strict
"scripts/inspect_dxpy.py" --strict
```
## Authentication
@@ -49,7 +62,7 @@ Use handlers for objects and executions:
| `DXApplet` | Project-local executable |
| `DXApp` | Versioned app |
| `DXWorkflow` | Native workflow |
| `DXJob` | App/appet execution |
| `DXJob` | App/applet execution |
| `DXAnalysis` | Workflow execution |
| `DXProject` | Project/data container |
@@ -368,7 +381,7 @@ read-modify-write races on shared open records.
## Run Executables
App/appet runs return `DXJob`:
App/applet runs return `DXJob`:
```python
job = dxpy.DXApplet(
@@ -429,27 +442,33 @@ from dxpy.exceptions import DXError, DXJobFailureError
try:
job.wait_on_done(interval=5, timeout=3600)
except DXJobFailureError:
failure = job.describe(
except DXJobFailureError as error:
status = job.describe(
fields={
"state": True,
"failureReason": True,
"failureMessage": True,
}
)
raise RuntimeError(
f"{failure.get('failureReason')}: "
f"{failure.get('failureMessage')}"
) from None
state = status.get("state")
if state not in {"failed", "terminated"}:
raise TimeoutError(
f"local wait ended while remote job state is {state!r}"
) from error
reason = status.get("failureReason") or "Terminated"
message = status.get("failureMessage") or str(error)
raise RuntimeError(f"{reason}: {message}") from error
except DXError as error:
raise RuntimeError(f"wait failed: {error}") from error
raise RuntimeError(f"polling failed: {error}") from error
outputs = job.describe(fields={"output": True})["output"]
```
Defaults for `DXJob.wait_on_done()` and `DXAnalysis.wait_on_done()` are a
two-second poll interval and a seven-day timeout. Set an explicit timeout that
matches the caller's needs.
matches the caller's needs. In dxpy 0.410.0, `DXJobFailureError` represents
remote failure, termination, **or local wait timeout** despite the method
docstring; re-describe state before classifying it.
To chain jobs, avoid waiting:
@@ -466,7 +485,8 @@ Current public dxpy exception classes include:
- `DXError`: base SDK error
- `DXAPIError`: non-200 API response
- `DXJobFailureError`: job/analysis wait detected failure
- `DXJobFailureError`: job/analysis wait detected failure, termination, or
local timeout; re-describe remote state to distinguish them
- `DXSearchError`: invalid or failed search
- `DXFileError`: file operation failure
- `DXChecksumMismatchError`: transfer integrity failure
@@ -140,7 +140,7 @@ The previous skill version contained examples that should not be copied:
| `DXFile.open_file()` | Use `dxpy.open_dxfile()` |
| `name="*.bam"` without mode | Add `name_mode="glob"` |
| `ResourceNotFound` imported as dxpy exception | Inspect `DXAPIError.name` |
| `job.wait_on_done()` followed by state branch | It raises `DXJobFailureError` on failure |
| Treating every `wait_on_done()` exception as remote failure | In dxpy 0.410.0, `DXJobFailureError` also covers termination and local wait timeout; re-describe state |
| Runtime `pip install` as primary dependency strategy | Prefer pinned venv/assets/saved images |
| Pulling floating Docker tags | Pin digest and preferably store `docker save` tarball |
| `dxpy.dxlink(job.get_output_ref(...))` | Pass `get_output_ref()` directly |
@@ -157,7 +157,7 @@ When updating this skill:
```bash
uv run --with "dxpy==<new-version>" \
"skills/dnanexus-integration/scripts/inspect_dxpy.py" --strict
"scripts/inspect_dxpy.py" --strict
```
5. Compare `dx build --help`, `dx run --help`, and search command help.
@@ -15,7 +15,7 @@ JSON, and generated executable IDs together as provenance.
## Native Workflows
Native workflows connect app/appet stages. Build from a `dxworkflow.json`:
Native workflows connect app/applet stages. Build from a `dxworkflow.json`:
```bash
dx build --workflow "path/to/workflow-source" \
@@ -156,7 +156,7 @@ without conformance tests.
## Nextflow
Creating a DNAnexus app/appet from Nextflow source requires a DNAnexus license.
Creating a DNAnexus app/applet from Nextflow source requires a DNAnexus license.
Current dx-toolkit supports Nextflow engine versions `25.10` and `24.10`;
`25.10` is the current default and `24.10` is retained only as an unmaintained
compatibility option.