This release is a pre-release and may not be stable for production use.
quapp-hpc
Python library cho Quapp HPC functions — cầu nối giữa Quapp FaaS platform và Slurm HPC cluster.
Architecture
ksvc (Docker)
├── index.py FastAPI server
├── quapp_hpc/
│ ├── factory/
│ │ └── hpc_handler_factory.py Entry point cho user
│ ├── component/backend/
│ │ └── hpc_invocation.py Orchestrates job lifecycle
│ └── model/
│ ├── provider/slurm_provider.py Auth headers, base URL
│ └── device/slurm_device.py Submit → Poll → S3 download
└── function/
└── handler.py User-defined processing() + post_processing()
Luồng thực thi
index.py nhận HTTP POST
→ HpcHandlerFactory.create_handler(event, processing_fn, post_processing_fn)
→ InvocationHandler.handle()
→ HpcInvocation.submit_job()
1. processing_fn(invocation_input) → bash script string
2. SlurmDevice._create_job(script) → POST Slurm REST API → slurm_job_id
3. SlurmDevice._get_job_result() → poll mỗi 30s → COMPLETED/FAILED
4. SlurmDevice._download_s3_result()→ boto3 get s3://$S3_BUCKET/$JOB_UUID/output.json
5. post_processing_fn(s3_result) → final response
Environment variables (từ K8s Secret slurm-credentials)
| Var | Ví dụ | Mô tả |
|---|---|---|
SLURM_API_URL |
http://10.1.0.15:6820 |
Slurm REST API base URL |
SLURM_JWT |
eyJ... |
JWT token cho Slurm auth |
SLURM_USERNAME |
quapp-svc |
Slurm username |
SLURM_ACCOUNT |
quapp |
Slurm account/allocation |
S3_BUCKET |
quapp-slurm-output-dev |
S3 bucket cho job output |
AWS_REGION |
ap-southeast-1 |
AWS region |
SLURM_POLL_SEC |
30 |
Polling interval (giây) |
SLURM_TIMEOUT_SEC |
21600 |
Max wait time (giây, default 6h) |
invocation_input schema
Xem chi tiết tại ../qapp-sdk-templates/slurm-hpc/README.md.
Tóm tắt:
{
"resources": { "partition", "nodes", "cpus_per_task", "gpus", "memory_gb", "time_limit" },
"container": { "type": "sif"|"docker"|"none", "image": "..." },
"job": { "type": "script"|"command", "script"|"command": "...", "environment": {}, "input_s3_paths": [] }
}
Slurm REST API
- Version:
v0.0.40 - Submit:
POST {SLURM_API_URL}/slurm/v0.0.40/job/submit - Status:
GET {SLURM_API_URL}/slurm/v0.0.40/job/{job_id} - Auth headers:
X-SLURM-USER-NAME,X-SLURM-USER-TOKEN
Job state mapping
| Slurm state | Quapp state |
|---|---|
| PENDING, CONFIGURING, RUNNING, COMPLETING | RUNNING |
| COMPLETED | DONE |
| FAILED, CANCELLED, TIMEOUT, NODE_FAIL, PREEMPTED | ERROR |
S3 output pattern
Job script phải upload kết quả:
aws s3 cp /tmp/output.json s3://$S3_BUCKET/$JOB_UUID/output.json
$JOB_UUID và $S3_BUCKET được inject tự động bởi SlurmDevice._create_job() qua Slurm environment array.
K8s Secret
# infrastructure/quapp-job-scheduler/k8s/cts/slurm-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: slurm-credentials
namespace: quapp-functions-dev
stringData:
SLURM_JWT: "<generate: sudo scontrol token username=quapp-svc lifespan=2592000>"
SLURM_API_URL: "http://10.1.0.15:6820"
SLURM_USERNAME: "quapp-svc"
SLURM_ACCOUNT: "quapp"
S3_BUCKET: "quapp-slurm-output-dev"
AWS_REGION: "ap-southeast-1"
DB seed required
Chạy script trước khi deploy:
infrastructure/quapp-functions-backend/docs/db/seed_slurm_hpc.sql
Metadata
Release files for quapp-hpc 0.0.1.dev8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| quapp_hpc-0.0.1.dev8.tar.gz | 18.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quapp_hpc-0.0.1.dev8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.9 kB
Release files / quapp_hpc-0.0.1.dev8.tar.gz
| Download URL | quapp_hpc-0.0.1.dev8.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
841d1c237bb19f49846d645e2b5f921571f748aa44cdd0b6d678bbab3cf7d53c
|
|
BLAKE2b-256 checksum How to use checksums |
95a0d74c5be018799afe4f370281e542bdd699a3a675c3feca5e48efa0d4028f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / quapp_hpc-0.0.1.dev8-py3-none-any.whl
| Download URL | quapp_hpc-0.0.1.dev8-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
562e1700c7eb488c271ebb835b9c0a62c46f01ea9a91c3ed8068d5a632aa2611
|
|
BLAKE2b-256 checksum How to use checksums |
a584370bae6346363512594a74f8a5559f20933c168d2872b41cd77279bc1094
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for quapp-hpc 0.0.1.dev8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.