Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions docs/user-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,33 @@ info (`supported_filesystem_protocols`). **Use the plain form** goes back
to the form without a schema; without a schema, Krini always uses that
form.

### Outputs of runs from I/O Schemas

A run that Krini starts from an I/O Schema records where the schema came
from in the run's tags: `io_schema.source` (`trs`, `url` or `upload`),
`io_schema.trs_url`, `io_schema.tool_id`, `io_schema.version_id`,
`io_schema.descriptor_type` and, for a schema by URL, `io_schema.url`.
When you open the run's details, Krini finds the schema again from these
tags, from the tool registry or the URL, and the **Outputs** tab shows
each output by its title and description, in the schema's order. Outputs
of runs that didn't complete are marked as partial.

- An **uploaded schema** can't be found again: the run's outputs are
shown as the WES service reports them, and the page says why.
- If the schema **can't be loaded** (e.g. the tool registry is
unreachable), the page says so and shows the outputs as reported.
- Runs **without these tags**, such as runs from the plain form, show
their outputs as before.

The tags only help Krini find the schema; they aren't checked, and you
can change them on runs you start yourself.

Viewing and downloading output files (tables, reports) needs a way for
your browser to fetch them from the WES service. Conquest reports its
outputs as `s3://` URIs in the run's bucket and offers no route for users
to fetch them yet, so on Conquest the outputs are shown with their titles,
descriptions and URIs only.

## Privacy

The privacy notice at `/privacy`, linked from the login page and the
Expand Down
18 changes: 18 additions & 0 deletions e2e/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ async function wesRequests(): Promise<WesRequest[]> {
return response.json();
}

/**
* Add a run to the mock WES service, as the service would report it
* @param run The run: ID, state, run request and outputs
*/
async function addWesRun(run: {
run_id: string;
state: string;
request?: Record<string, unknown>;
outputs?: unknown;
}): Promise<void> {
const response = await fetch(`${mock}/mock/runs`, {
method: "POST",
body: JSON.stringify(run),
});
if (!response.ok) throw new Error(`mock run: HTTP ${response.status}`);
}

/**
* Get all requests that the mock TES service received
* @returns The requests, oldest first
Expand Down Expand Up @@ -160,6 +177,7 @@ const test = base.extend<Fixtures>({

export {
accessToken,
addWesRun,
expect,
expireAccessToken,
forgiveProblems,
Expand Down
76 changes: 76 additions & 0 deletions e2e/io-schema-outputs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @description Run outputs with I/O Schema hints (krini#132): Krini records
* where a run's I/O Schema came from in the run's tags, finds the schema
* again from them, and the run view shows the outputs by the schema's
* titles and descriptions. Runs from uploaded schemas show their outputs
* as the service reports them, and say why
*/
import { addWesRun, expect, login, test } from "./fixtures";
import { mockHttpsPort } from "./settings";

const trsUrl = `https://127.0.0.1:${mockHttpsPort}/ga4gh/trs/v2`;
const tags = {
"io_schema.source": "trs",
"io_schema.trs_url": trsUrl,
"io_schema.tool_id": "io-schema-word-count",
"io_schema.version_id": "1.0.0",
"io_schema.descriptor_type": "CWL",
};
const request = {
workflow_url: `${trsUrl}/tools/io-schema-word-count/versions/1.0.0/PLAIN_CWL/descriptor/wc.cwl`,
workflow_type: "CWL",
workflow_type_version: "v1.2",
};
const count = "https://example.org/runs/run-io/count.txt";

test.describe("members", () => {
test.beforeEach(async ({ page }) => {
await login(page);
});

test("see the outputs of a run by its I/O Schema", async ({ page }) => {
await addWesRun({
run_id: "run-io",
state: "COMPLETE",
request: { ...request, tags },
outputs: { count },
});
await page.goto(
"/dashboard/workflows/details?id=run-io&service=mock-wes",
);
await page.getByRole("tab", { name: /Outputs/ }).click();
// the output's title and description come from the schema
await expect(page.getByText("Count", { exact: true })).toBeVisible();
await expect(
page.getByText(
"The count and the name of the file, as wc prints them.",
),
).toBeVisible();
});

test("see why the outputs of a run from an uploaded schema have no hints", async ({
page,
}) => {
await addWesRun({
run_id: "run-upload",
state: "COMPLETE",
request: {
...request,
tags: { ...tags, "io_schema.source": "upload" },
},
outputs: { count },
});
await page.goto(
"/dashboard/workflows/details?id=run-upload&service=mock-wes",
);
await expect(page.getByRole("status")).toContainText(
"uploaded I/O Schema",
);
await page.getByRole("tab", { name: /Outputs/ }).click();
await expect(
page.getByText(
"The count and the name of the file, as wc prints them.",
),
).toHaveCount(0);
});
});
8 changes: 8 additions & 0 deletions e2e/io-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ test.describe("members", () => {
text: { class: "File", location: text },
unit: "words",
});
// where the schema came from, for the run view (#132)
expect(JSON.parse(submission.fields?.tags ?? "")).toEqual({
"io_schema.source": "trs",
"io_schema.trs_url": trsUrl,
"io_schema.tool_id": "io-schema-word-count",
"io_schema.version_id": "1.0.0",
"io_schema.descriptor_type": "CWL",
});

// back to the plain form
await page.getByRole("button", { name: "Use the plain form" }).click();
Expand Down
46 changes: 43 additions & 3 deletions e2e/mock/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,14 @@ const revokedRefreshTokens = new Set<string>();
/** How the provider answers refresh token grants (`/mock/refresh`) */
let refreshMode: RefreshMode = {};
/** Runs that the WES service accepted */
const runs: { run_id: string; state: string }[] = [];
/** Runs of the mock WES service: what `GET /runs/{id}` answers */
type MockRun = {
run_id: string;
state: string;
request?: Record<string, unknown>;
outputs?: unknown;
};
const runs: MockRun[] = [];
/** Requests that the WES service received, for the tests */
const requests: WesRequest[] = [];
/** Tasks that the TES service accepted */
Expand Down Expand Up @@ -368,6 +375,13 @@ async function handleHttp(req: IncomingMessage, res: ServerResponse) {
if (req.method === "GET" && url.pathname === "/mock/tes-requests")
return send(res, 200, tesRequests);

// a run as the WES service would report it, e.g. a finished one
if (req.method === "POST" && url.pathname === "/mock/runs") {
const run = JSON.parse(await bodyOf(req)) as MockRun;
runs.push(run);
return send(res, 201, run);
}

if (req.method === "POST" && url.pathname === "/mock/reset") {
requests.length = 0;
runs.length = 0;
Expand Down Expand Up @@ -555,6 +569,7 @@ async function handleHttps(req: IncomingMessage, res: ServerResponse) {
"workflow_type",
"workflow_type_version",
"workflow_params",
"tags",
].map((name) => [name, String(form?.get(name) ?? "")]),
);
requests[requests.length - 1].fields = fields;
Expand All @@ -575,7 +590,27 @@ async function handleHttps(req: IncomingMessage, res: ServerResponse) {
{ msg: "invalid run request", status_code: 400 },
cors,
);
const run = { run_id: `run-${runs.length + 1}`, state: "QUEUED" };
let tags: unknown = {};
try {
tags = fields.tags ? JSON.parse(fields.tags) : {};
} catch {
return send(
res,
400,
{ msg: "invalid run request", status_code: 400 },
cors,
);
}
const run: MockRun = {
run_id: `run-${runs.length + 1}`,
state: "QUEUED",
request: {
workflow_url: fields.workflow_url,
workflow_type: fields.workflow_type,
workflow_type_version: fields.workflow_type_version,
tags,
},
};
runs.push(run);
return send(res, 200, { run_id: run.run_id }, cors);
}
Expand All @@ -585,7 +620,12 @@ async function handleHttps(req: IncomingMessage, res: ServerResponse) {
return send(
res,
200,
{ run_id: run.run_id, state: run.state, request: {} },
{
run_id: run.run_id,
state: run.state,
request: run.request ?? {},
...(run.outputs === undefined ? {} : { outputs: run.outputs }),
},
cors,
);

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@base-ui/react": "^1.9.0",
"@elixir-cloud/tes": "^2.0.0-alpha.51",
"@elixir-cloud/wes": "file:./vendor/cloud-components/elixir-cloud-wes-2.0.0-alpha.51-io.f28c15c.tgz",
"@elixir-cloud/wes": "file:./vendor/cloud-components/elixir-cloud-wes-2.0.0-alpha.51-io.c24a517.tgz",
"axios": "^1.20.0",
"class-variance-authority": "^0.7.1",
"cn": "^0.5.0",
Expand Down Expand Up @@ -55,6 +55,6 @@
"overrides": {
"body-parser": "^2.4.0",
"systeminformation": "^5.33.16",
"@elixir-cloud/design": "file:./vendor/cloud-components/elixir-cloud-design-2.0.0-alpha.51-io.f28c15c.tgz"
"@elixir-cloud/design": "file:./vendor/cloud-components/elixir-cloud-design-2.0.0-alpha.51-io.c24a517.tgz"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import dynamic from "next/dynamic";
import { useRef, useState } from "react";
import { useMemo, useRef, useState } from "react";
import { ExampleButtons } from "@/components/shared/example-buttons";
import { useWESProvider } from "@/hooks";
import { withSelfHostedAce } from "@/lib/ace-workers";
Expand All @@ -11,6 +11,7 @@ import {
engineProfileFor,
type IoSchemaDemo,
} from "@/lib/io-schema";
import { provenanceTags, withRunTags } from "@/lib/run-schema";
import type { SchemaRun } from "@/lib/schema-run";
import { useWESStore } from "@/stores/wes";
import { IoSchemaSource } from "./io-schema-source";
Expand Down Expand Up @@ -48,6 +49,18 @@ export function ECCClientGa4ghWesCreateRunsClient({
// schema mode: the I/O Schema and the TRS tool version to run (#47)
const [schemaRun, setSchemaRun] = useState<SchemaRun | null>(null);
const [schemaKey, setSchemaKey] = useState(0);
// runs from a schema record where it came from, so that the run view
// can find it again (#132)
const schemaProvider = useMemo(
() =>
wesProvider === null || schemaRun === null
? null
: withRunTags(
wesProvider,
provenanceTags(schemaRun.provenance),
),
[wesProvider, schemaRun],
);

if (
selectedServer === null ||
Expand Down Expand Up @@ -105,7 +118,7 @@ export function ECCClientGa4ghWesCreateRunsClient({
) : (
<ECCClientGa4ghWesCreateRuns
key={`schema-${schemaKey}`}
provider={wesProvider}
provider={schemaProvider ?? wesProvider}
ioSchema={schemaRun.schema}
trsToolVersion={schemaRun.trsToolVersion}
engineProfile={
Expand Down
Loading