Py4HEAppE (Python for HEAppE Middleware)
Release: 5.0.0
Py4HEAppE provides both a command-line interface and versioned Python wrappers for the HEAppE middleware API.
You can use it in two ways:
- HEAppE CLI commands for interactive and scripting use
- Versioned Python API wrappers for direct integration into your own applications
Supported HEAppE Versions
| Py4HEAppE | HEAppE Version | Notes |
|---|---|---|
| 5.0.X | 6.5.X, 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | Adds asyncio v6 wrapper (core_async); hand-written v6 code moved to extensions/ |
| 4.0.X | 6.5.X, 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | OpenAPI Generator-based v6 wrapper |
| 3.2.X | 6.5.X, 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 3.1.X | 6.5.X, 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.9.X | 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.8.X | 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.7.X | 6.4.X, 6.3.X, 6.2.X, 6.2.1, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.6.X | 6.3.X, 6.2.X, 6.1.X, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.5.X | 6.3.X, 6.2.X, 6.1.X, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.4.X | 6.1.X, 6.0.X, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.3.X | 6.0.X, 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.2.X | 5.0.X, 4.3.X, 4.2.X | Without Admin CLI section |
| 2.1.X | 5.0.X, 4.3.X, 4.2.X | Without Admin, Job, and File CLI sections |
| 2.0.X | 5.0.X | Without Admin, Job, and File CLI sections |
| 1.X.X | 4.3.X, 4.2.X | Without Admin, Job, and File CLI sections |
Requirements
- Python 3.11 or newer
- Access to a deployed HEAppE instance
- HEAppE instance URL
- HEAppE accounting string for the target computational project
Installation
If the py4heappe executable is not on your PATH, use the full path to the installed script or add the script directory to PATH.
On Windows, use py4heappe.exe instead of py4heappe.
To use the asynchronous Python wrapper (heappe_v6.core_async), install the optional async extra, which adds aiohttp and aiohttp-retry:
pip install "py4heappe[async]"
HEAppE CLI
The CLI is intended for users who want to work with HEAppE directly from a terminal without writing Python code.
Initial Setup
Before using the CLI for the first time, initialize the HEAppE instance URL and the accounting string:
py4heappe Conf Init
Available Command Groups
py4heappe --help
Current command groups:
Conffor local CLI configurationAuthfor authenticationCmdTempfor command template operationsInfofor version and cluster informationJobfor job lifecycle managementFileTransferfor job file upload and download operationsReportfor resource usage and reporting
Useful Help Commands
py4heappe Auth --help
py4heappe Info --help
py4heappe Job --help
py4heappe FileTransfer --help
py4heappe Report --help
Basic CLI Examples
Authenticate with username and password:
py4heappe Auth UserPass
Show the HEAppE API version:
py4heappe Info Version
List available clusters:
py4heappe Info ClusterInfo
List your jobs:
py4heappe Job List
Create a Job from a JSON Template
Py4HEAppE supports a JSON-first workflow for job creation.
Generate a minimal job specification template in the current directory:
py4heappe Job InitJobSpecification
Generate the full OpenAPI-shaped job specification template instead:
py4heappe Job InitJobSpecification --full
Or generate it in a specific directory or target file:
py4heappe Job InitJobSpecification --file-destination ./job_specs
py4heappe Job InitJobSpecification --file-destination ./job_specs/demo_job.json
Create a job from the JSON file and override selected values from the command line:
py4heappe Job Create --json-job-spec-file ./job_specification.json \
--name demo-job \
--cluster-id 2 \
--project-id 1 \
--task-name 0:demo-task \
--task-max-cores 0:128 \
--walltime-limit 0:1800 \
--cluster-node-type-id 0:18 \
--cmd-template-id 0:3 \
--cmd-template-parameters inputParam:testValue
CLI overrides always take precedence over values loaded from --json-job-spec-file.
Save the final parsed job specification that will be submitted to HEAppE:
py4heappe Job Create --json-job-spec-file ./job_specification.json \
--save-result-job-specification
This writes resultJobSpecJson.json into the current working directory.
Override Format for Nested Task Data
Some Job Create options work on indexed task items and nested collections.
Examples:
# Task scalar override
py4heappe Job Create --json-job-spec-file ./job_specification.json --task-name 0:main-task
# Task environment variable override
py4heappe Job Create --json-job-spec-file ./job_specification.json \
--task-environment-variable 0:0:Name:OMP_NUM_THREADS \
--task-environment-variable 0:0:Value:8
# Task template parameter override
py4heappe Job Create --json-job-spec-file ./job_specification.json \
--task-template-parameter-value 0:0:CommandParameterIdentifier:inputParam \
--task-template-parameter-value 0:0:ParameterValue:testValue
File Transfer Examples
List files changed during job execution:
py4heappe FileTransfer ListChanged --help
Download a single file from a job directory:
py4heappe FileTransfer Download --help
Upload files directly into the job execution directory:
# Upload one or more local files from disk
py4heappe FileTransfer Stream --id 12345 --files ./input_a.dat --files ./input_b.dat
# Upload a single file from stdin bytes
Get-Content -Path .\input.dat -AsByteStream | py4heappe FileTransfer Stream --id 12345 --stdin --upload-filename input.dat
# Upload a single file from base64 content
py4heappe FileTransfer Stream --id 12345 --base64 aGVsbG8gd29ybGQ= --upload-filename hello.txt
Python API Wrapper
Py4HEAppE also ships versioned Python wrappers generated from the HEAppE API.
Since 4.0.0, the heappe_v6 wrapper is generated with OpenAPI Generator. Legacy
CLI call signatures (for example SessionCode and _preload_content=False)
remain supported through an internal compatibility shim. Since 5.0.0, heappe_v6
also ships an asyncio wrapper (see Asynchronous Python API Wrapper).
Hand-written heappe_v6 code lives in py4heappe.heappe_v6.extensions (moved from core/ in 5.0.0):
the in-memory upload extension is py4heappe.heappe_v6.extensions.file_transfer_api_ext.
Use the wrapper that matches your target HEAppE version:
import py4heappe.heappe_v6.core as hp
# or:
# import py4heappe.heappe_v5.core as hp
# import py4heappe.heappe_v4.core as hp
There is no single unversioned py4heappe.core module. Use the versioned wrapper explicitly.
Dedicated In-Memory Upload API (file_transfer_api_ext.py)
For uploads that should not touch local disk files, use the dedicated implementation in
src/py4heappe/heappe_v6/extensions/file_transfer_api_ext.py.
It provides FileTransferApiExt.heappe_file_transfer_upload_file_objects_to_job_execution_dir_post,
which accepts byte-like payloads or file-like objects.
import io
import py4heappe.heappe_v6.core as hp
from py4heappe.heappe_v6.extensions.file_transfer_api_ext import (
FileTransferApiExt,
InMemoryUploadFile,
)
configuration = hp.Configuration()
configuration.host = "https://heappe.example.org"
api_client = hp.ApiClient(configuration)
stream_api = FileTransferApiExt(api_client)
stream_api.heappe_file_transfer_upload_file_objects_to_job_execution_dir_post(
files=[
InMemoryUploadFile("bytes-input.txt", b"hello from bytes"),
("stream-input.bin", io.BytesIO(b"\\x00\\x01\\x02"), "application/octet-stream"),
],
session_code="your-session-code",
job_id=12345,
task_id=1,
_preload_content=False,
)
Minimal Python Example
import json
import py4heappe.heappe_v6.core as hp
configuration = hp.Configuration()
configuration.host = "https://heappe.example.org"
api_client = hp.ApiClient(configuration)
try:
auth_api = hp.UserAndLimitationManagementApi(api_client)
management_api = hp.ManagementApi(api_client)
cluster_api = hp.ClusterInformationApi(api_client)
auth_body = {
"_preload_content": False,
"body": {
"Credentials": {
"Username": "username",
"Password": "password",
}
},
}
auth_response = auth_api.heappe_user_and_limitation_management_authenticate_user_password_post(
**auth_body
)
session_code = json.loads(auth_response.data)
version_response = management_api.heappe_management_version_information_get(
_preload_content=False,
SessionCode=session_code,
)
print(json.dumps(json.loads(version_response.data), indent=2))
cluster_response = cluster_api.heappe_cluster_information_list_available_clusters_get(
_preload_content=False,
SessionCode=session_code,
)
print(json.dumps(json.loads(cluster_response.data), indent=2))
finally:
api_client.pool.close()
api_client.pool.join()
Create a Job Through the Python Wrapper
import json
import py4heappe.heappe_v6.core as hp
configuration = hp.Configuration()
configuration.host = "https://heappe.example.org"
api_client = hp.ApiClient(configuration)
try:
job_api = hp.JobManagementApi(api_client)
body = {
"_preload_content": False,
"body": {
"SessionCode": "your-session-code",
"JobSpecification": {
"Name": "demo-job",
"ProjectId": 1,
"ClusterId": 2,
"FileTransferMethodId": 1,
"Tasks": [
{
"Name": "demo-task",
"MinCores": 1,
"MaxCores": 16,
"WalltimeLimit": 1800,
"StandardOutputFile": "stdout",
"StandardErrorFile": "stderr",
"ProgressFile": "stdprog",
"LogFile": "stdlog",
"ClusterNodeTypeId": 18,
"CommandTemplateId": 3,
"TemplateParameterValues": [
{
"CommandParameterIdentifier": "inputParam",
"ParameterValue": "testValue",
}
],
}
],
},
},
}
response = job_api.heappe_job_management_create_job_post(**body)
job_id = json.loads(response.data)["Id"]
print(f"Created job: {job_id}")
finally:
api_client.pool.close()
api_client.pool.join()
Asynchronous Python API Wrapper
heappe_v6 also ships an asyncio wrapper, py4heappe.heappe_v6.core_async, generated
from the same OpenAPI definition with OpenAPI Generator's asyncio (aiohttp) library.
It requires the optional extra: pip install "py4heappe[async]".
It differs from the synchronous wrapper in a few ways:
- Every API method is a coroutine and must be awaited.
- Methods use the generated snake_case signatures and request models
(for example
session_code=...). The legacySessionCode,body=and_preload_content=Falsecompatibility shim applies only to the synchronous wrapper. - Each operation comes in three variants: the plain method returns the deserialized
data,
..._with_http_inforeturns anApiResponse(status code, headers, data), and..._without_preload_contentreturns the raw, unread response. - Close the client with
async with hpa.ApiClient(...)orawait api_client.close(). Theapi_client.poolcleanup used by the synchronous wrapper does not apply.
import asyncio
import py4heappe.heappe_v6.core_async as hpa
async def main():
configuration = hpa.Configuration(host="https://heappe.example.org")
async with hpa.ApiClient(configuration) as api_client:
session_code = await hpa.UserAndLimitationManagementApi(
api_client
).heappe_user_and_limitation_management_authenticate_user_password_post(
authenticate_user_password_model=hpa.AuthenticateUserPasswordModel(
credentials=hpa.PasswordCredentialsExt(
username="your-username", password="your-password"
)
)
)
# Independent requests run concurrently on one client.
version, clusters = await asyncio.gather(
hpa.ManagementApi(api_client).heappe_management_version_information_get(
session_code=session_code
),
hpa.ClusterInformationApi(
api_client
).heappe_cluster_information_list_available_clusters_get(
session_code=session_code
),
)
print(version.version, [cluster.name for cluster in clusters])
asyncio.run(main())
For in-memory uploads, use the async counterpart of FileTransferApiExt:
from py4heappe.heappe_v6.extensions.file_transfer_api_ext_async import (
FileTransferApiExt,
InMemoryUploadFile,
)
await FileTransferApiExt(
api_client
).heappe_file_transfer_upload_file_objects_to_job_execution_dir_post(
files=[InMemoryUploadFile("bytes-input.txt", b"hello from bytes")],
session_code=session_code,
job_id=12345,
)
Besides bytes and regular file-like objects, the async extension accepts async file objects whose read() is awaited, such as aiofiles handles. Regular file-like objects are read in a worker thread, so a large file never blocks the event loop:
import aiofiles
async with aiofiles.open("input.bin", "rb") as f:
await FileTransferApiExt(api_client).heappe_file_transfer_upload_file_objects_to_job_execution_dir_post(
files=[("input.bin", f)],
session_code=session_code,
job_id=12345,
)
A complete runnable example is in docs/examples/example_async.py.
Running CLI tests
The repository includes live CLI integration tests under tests/ that require a reachable HEAppE instance and several environment variables.
Quick steps:
-
Create a
tests/.envfrom the example and edit it:- Unix:
cp tests/.env.example tests/.env - Windows (PowerShell):
Copy-Item tests\.env.example tests\.env
- Unix:
-
Populate required values in
tests/.env(or export the variables). At minimum setPY4HEAPPE_RUN_LIVE_CLI_TESTS=1andPY4HEAPPE_TEST_URLandPY4HEAPPE_TEST_PROJECT. To allow tests that change remote state also setPY4HEAPPE_TEST_RUN_MUTATING_COMMANDS=1. -
Run the CLI tests (default, using the standard library's unittest):
- Run all CLI tests:
python -m unittest discover -s tests -p "test_cli_*.py" -v - Run a single test module:
python -m unittest tests.test_cli_auth -v
- Run all CLI tests:
-
Optional: run with pytest (pytest can run unittest-style tests and offers improved output):
- Install pytest:
python -m pip install -U pytest - Run with pytest:
python -m pytest -q tests/test_cli_*.py
- Install pytest:
The tests/ folder also contains two example scripts that upload in-memory files to a job with the sync and async FileTransferApiExt, as you would in your own code. They use the local sources in src/, are not run by unittest discovery, and read these values from tests/.env: PY4HEAPPE_TEST_URL, PY4HEAPPE_TEST_SESSION_CODE (for example from py4heappe Auth UserPass), PY4HEAPPE_TEST_STREAM_JOB_ID and, optionally, a single PY4HEAPPE_TEST_STREAM_TASK_ID. Run them from the repository root:
- Sync:
python tests/example_file_transfer_api_ext.py - Async (needs the
asyncextra):python tests/example_file_transfer_api_ext_async.py
Do NOT commit tests/.env with real credentials or session tokens.
Notes
- CLI configuration is stored locally after
py4heappe Conf Init. - Most CLI commands require a valid session, so authenticate before running job or file-transfer operations.
- For detailed option lists, use the built-in
--helpon each command group and subcommand.
Acknowledgement
This work was supported by the Ministry of Education, Youth and Sports of the Czech Republic through e-INFRA CZ (ID:90254).
Metadata
Release files for Py4HEAppE 5.0.0
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 |
|---|---|---|---|---|
| py4heappe-5.0.0.tar.gz | 816.4 kB | Without provenance | Details for py4heappe-5.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py4heappe-5.0.0-py3-none-any.whl | Python 3 | none | any | Details for py4heappe-5.0.0-py3-none-any.whl |
Total release size: 2.4 MB
Release files / py4heappe-5.0.0.tar.gz
| Download URL | py4heappe-5.0.0.tar.gz |
|---|---|
| Size | 816.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2fd24bafe013ae80c804f541c8871eb90bda92113cac48c3e97ed0bda74f6a0
|
|
BLAKE2b-256 checksum How to use checksums |
e69786fb7699e459161a66f8cd9aa2e22a324be2b9063851159b0c7a58c75bd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.18
|
Release files / py4heappe-5.0.0-py3-none-any.whl
| Download URL | py4heappe-5.0.0-py3-none-any.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7751d0e61f9c6b394e56879488cfe033e2853df280d290b9b4c7268882e7beef
|
|
BLAKE2b-256 checksum How to use checksums |
f032cfcd78a5719858362255178ce1638545d2af0072d935083dfdc73cc75401
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.18
|
Security for Py4HEAppE 5.0.0
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.