Metadata-Version: 2.4
Name: haps-plugin-scheduler-client
Version: 0.4.1
Summary: Read the HPC scheduling information of a HAPS job, and ask for its cancellation
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: haps-client==0.4.*
Requires-Dist: ebcommon==2.0.0a0

# haps-plugin-scheduler-client

The user's half of the HAPS scheduler plugin. Submit a job to an application
that runs on an HPC centre, follow it, and collect its output — without an
account on that centre.

```bash
pip install haps-plugin-scheduler-client
```

## Submit

```python
from haps_client import HapsClient
from haps_plugin_scheduler_client import SchedulerClient

api = HapsClient(username=..., password=..., ebservice_url=..., ebuffer_url=...)

sched = SchedulerClient(api, ms_uuid)      # refused if the application is not made for this plugin
sched.mservice_summary()                   # what it expects, in order

sched.submit_job(
    [],                                    # arguments
    ebin=[tpr.uuid],                       # input buffers, created and filled by you
    ebout=[b.uuid for b in outputs],       # output buffers, matched by position
)
print(sched.job_uuid)                      # the one thing to write down
```

Add `dry_run=True` to have Slurm check the job without running it: nothing is
queued, no hours are spent.

## Follow

```python
sched.monitor()          # prints each change until the job is over
sched.job_summary()      # a snapshot: statuses, Slurm job id, elapsed time
```

Two statuses side by side, HAPS's and Slurm's:

```
PROCESSING (PENDING)     waiting in the Slurm queue
PROCESSING (RUNNING)     running on the centre
COMPLETED  (COMPLETED)   done
FAILED     (TIMEOUT)     the walltime was exceeded
```

Closed your laptop? The job carries on. Pick it back up anywhere:

```python
sched = SchedulerClient.attach(api, job_uuid)
SchedulerClient.list(api)       # every job you submitted through the plugin
```

## Collect

```python
sched.download_data("./results")        # the output buffers: what the calculation made
sched.download_slurm_trace("./trace")   # what it printed on the centre, stdout and stderr
```

The trace is the first place to look when a job ends in `FAILED`. It is kept
for a limited time only.

## Cancel

```python
sched.cancel_job()
```

The Slurm job is stopped within a minute.
