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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
quapp_hpc-0.0.1.tar.gz
(15.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
quapp_hpc-0.0.1-py3-none-any.whl
(18.4 kB
view details)
File details
Details for the file quapp_hpc-0.0.1.tar.gz.
File metadata
- Download URL: quapp_hpc-0.0.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e9e545e524d1e6b063eafba428da214a41c2bc6fc9af5f6caf879a195f9051
|
|
| MD5 |
8519a6141cd6625a3bc69be22b9d7dc8
|
|
| BLAKE2b-256 |
4e033f4a8d09d0f98ae726f31f6dacba1d3b69bdc67c608bca684aa703be3fcb
|
File details
Details for the file quapp_hpc-0.0.1-py3-none-any.whl.
File metadata
- Download URL: quapp_hpc-0.0.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
019bc12516aff865b7a6dcf384009b7afe52b3ac019d31994f864026627694ee
|
|
| MD5 |
9f11677d14c405a647a0ade1e7f305f5
|
|
| BLAKE2b-256 |
ae75f6896c45b1e4d406ecf00eb13c2c5a67cccc2fb2c5c09fd06a37c1217695
|