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
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 | Actions |
|---|---|---|---|---|
| quapp_hpc-0.0.1.tar.gz | 15.8 kB | Without provenance | Details for quapp_hpc-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quapp_hpc-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for quapp_hpc-0.0.1-py3-none-any.whl |
Total release size: 34.2 kB
Release files / quapp_hpc-0.0.1.tar.gz
| Download URL | quapp_hpc-0.0.1.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05e9e545e524d1e6b063eafba428da214a41c2bc6fc9af5f6caf879a195f9051
|
|
BLAKE2b-256 checksum How to use checksums |
4e033f4a8d09d0f98ae726f31f6dacba1d3b69bdc67c608bca684aa703be3fcb
|
| 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-py3-none-any.whl
| Download URL | quapp_hpc-0.0.1-py3-none-any.whl |
|---|---|
| Size | 18.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
019bc12516aff865b7a6dcf384009b7afe52b3ac019d31994f864026627694ee
|
|
BLAKE2b-256 checksum How to use checksums |
ae75f6896c45b1e4d406ecf00eb13c2c5a67cccc2fb2c5c09fd06a37c1217695
|
| 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
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.