Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Follow the shortcuts in the following table to the individual demos.
| Name | First Demo | Description |
| --- | --- | --- |
| [2023-ecp-f2f](demos/2023-ecp-f2f/README.md) | ELIXIR Compute Face-to-Face, Helsinki, Feb 7-8, 2023 | Task execution via the [Task Execution Service (TES) API](https://github.com/ga4gh/task-execution-schemas/) on Kubernetes and HPC; TES-based task distribution with random and distance-based task distribution logic; execution of a CWL workflow via the `cwl-tes` TES backend |
| [federated-analytics](demos/federated-analytics/README.md) | Not yet given | The same analysis at two Nodes via TES tasks, optionally through the proTES gateway; only aggregates leave the Nodes and are combined into the result of the whole data set |

## Test data

Expand Down
104 changes: 104 additions & 0 deletions demos/federated-analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Demonstrator federated-analytics

Runs the same analysis at two Nodes through GA4GH TES, optionally through the
proTES gateway, and combines the results. Only aggregates leave the Nodes,
never the rows.

> [!IMPORTANT]
> The demo uses the synthetic test data of [`data/`](../../data/README.md).
> Never run it on real, personal or other sensitive data.

## How it works

1. The data set `synthetic-growth` has one partition per Node (`node-a`,
`node-b`). [`data/manifest.json`](../../data/manifest.json) lists their
URLs.
2. For each partition, [`federated_analytics.py`](federated_analytics.py)
sends one TES task. The task downloads the partition and runs
[`local_stats.py`](local_stats.py) in a `python:3.13-slim` container. The
script prints the count, sum and sum of squares of each value column per
condition, as JSON.
3. The client reads that output from the task logs (`view=FULL`, standard
output of the executor), so no object store is needed for outputs.
4. The client combines the aggregates into the mean and standard deviation per
condition, and Welch's t statistic of `treated` against `control`. The
result is exactly the one of all rows in one place; the tests check this.

## Quick start (no services)

From a fresh clone, with Python 3.12 or later:

```sh
python demos/federated-analytics/federated_analytics.py --local
```

`--local` runs `local_stats.py` on the local copies of the partitions instead
of in TES tasks. It works if the output ends like this:

```text
Welch's t (treated vs control), od600: 13.81
Welch's t (treated vs control), expression: 8.48
```

Add `--json` for machine-readable output. CI runs this quick start on every
change.

## Run against TES services

Through one proTES gateway (all tasks to the gateway, which routes them to its
TES instances):

```sh
export TES_TOKEN=<access token for the gateway>
python demos/federated-analytics/federated_analytics.py --tes https://protes.example.org
```

With one TES service per partition (in the order of the manifest: `node-a`,
then `node-b`):

```sh
python demos/federated-analytics/federated_analytics.py \
--tes https://tes.node-a.example.org \
--tes https://tes.node-b.example.org
```

| Option or variable | Meaning |
| --- | --- |
| `--tes URL` | Base URL of a TES service or gateway, without `/ga4gh/tes/v1`. Give it once (all tasks go there) or once per partition (in the order of the manifest); other counts are an error. |
| `TES_TOKEN` | Access token, sent as bearer token if set. proTES 0.3.0 and later need one, from an identity provider the gateway accepts (see [Access control](https://protes.readthedocs.io/en/latest/access-control/)). |
| `--image` | Container image with Python 3 for the tasks (default: `python:3.13-slim`). |
| `--manifest` | Manifest of the partitions (default: `data/manifest.json`). |
| `--poll` | Seconds between status requests (default: 5). |
| `--timeout` | Seconds to wait for each task, requests included (default: 1800). |

If a request or a task fails, the demo prints the error (with a hint for HTTP
401 and 403) and exits with code 1. It then asks the services to cancel the
tasks it has sent.

The demo sends `TES_TOKEN` only over HTTPS (plain HTTP only to `localhost`)
and refuses redirects, so that the token never goes to another origin. If a
partition has invalid data, `local_stats.py` names the row number and column
only, never values, so that no data leave the Node through the task logs.

The services need:

- to download the partitions from `raw.githubusercontent.com`, or copies of
them at URLs they can reach (edit a copy of the manifest and pass it with
`--manifest`);
- to accept inputs with `content` (TES 1.1), for the script;
- to report the standard output of executors in the task logs.

proTES routes each task to one of its TES instances at random, unless its
operator enables [routing by distance to the
data](https://protes.readthedocs.io/en/latest/plugins/#routing-by-distance-to-the-data-opt-in).
For the federated case, where each partition stays at its Node, place each
partition at its Node and enable that routing, or send each partition to its
Node's TES service directly.

## What has been run

- The quick start (`--local`) and the TES client against an in-memory fake TES
service, in the tests of this repository.
- **Not run:** against a deployed TES service or proTES gateway with access
tokens. Please report results in the
[issues](https://github.com/elixir-cloud-aai/elixir-cloud-demos/issues).
Loading
Loading