FirecREST¶
FirecREST is a RESTful API for programmatically accessing High-Performance Computing resources, developed at CSCS.
Users can make use of FirecREST to automate access to HPC, enabling CI/CD pipelines, workflow orchestrators, and other tools against HPC resources.
Additionally, scientific platform developers can integrate FirecREST into web-enabled portals and web UI applications, allowing them to securely access authenticated and authorized CSCS services such as job submission and data transfer on HPC systems.
Users can make HTTP requests to perform the following operations:
- basic system utilities like
ls,mkdir,mv,chmod,chown, among others - actions against the Slurm workload manager (submit, query, and cancel jobs of the user)
- internal (between CSCS systems) and external (to/from CSCS systems) data transfers
FirecREST specification¶
Version 2 of the FirecREST API is provided on Alps. See the following external documentation pages for more detailed information:
- FirecREST-v2 documentation: for detailed documentation.
- FirecREST-v2 API specification: for the full feature set.
Version 1 deprecation
FirecREST version 1 was decommissioned on Alps on December 5th, 2025
FirecREST Deployment on Alps¶
FirecREST is available for all three major Alps platforms, with a dedicated API endpoint for each platform.
| Platform | API Endpoint | Clusters |
|---|---|---|
| HPC Platform | https://api.cscs.ch/hpc/firecrest/v2 | Daint, Eiger |
| ML Platform | https://api.cscs.ch/ml/firecrest/v2 | Bristen, Clariden |
| C&W Platform | https://api.cscs.ch/cw/firecrest/v2 | Santis |
| Beverin | https://api.cscs.ch/beverin/firecrest/v2 | Beverin |
Accessing FirecREST¶
Clients and access tokens¶
For authenticating requests to FirecREST, client applications use an access token instead of directly using the user’s credentials. The access token is a signed JSON Web Token (JWT) which contains user information and is only valid for a short time (5 minutes). Behind the API, all commands launched by the client will use the account of the user that registered the client, inheriting their access rights.
Every client has a client ID (Consumer Key) and a secret (Consumer Secret) that are used to get a short-lived access token with an HTTP request.
curl call to fetch the access token
You can manage your client application on the CSCS Developer Portal.
To use your client credentials to access FirecREST, follow the API documentation.
Service Account API keys¶
Service Accounts provide programmatic, non-interactive access to CSCS resources. A Service Account API key can be used to authenticate requests to FirecREST instead of a personal client application. This is useful for automated workflows that need to call FirecREST but should not be tied to a personal user account or Developer Portal application.
Experimental
Calling FirecREST with a Service Account API key is an experimental service. The endpoints and the authentication flow described in this section can change without a deprecation period.
Service Accounts are not allowed to use these endpoints by default: each Service Account has to be explicitly allowlisted first. To request access, open a ticket at the CSCS Service Desk stating the name of the Service Account and the project it belongs to.
Requesting a Service Account
To use FirecREST with a Service Account you first need a Service Account and its API key. See Requesting a Service Account for how to create one.
Service Account requests are not sent to the platform endpoints, but to a separate proxy deployment at https://f7t-pat.api.svc.cscs.ch/<platform>, where the platform path selects which FirecREST deployment the request is forwarded to.
| Platform | Service Account endpoint | Clusters |
|---|---|---|
| HPC Platform | https://f7t-pat.api.svc.cscs.ch/hpcp |
Daint, Eiger |
| ML Platform | https://f7t-pat.api.svc.cscs.ch/mlp |
Bristen, Clariden |
| C&W Platform | https://f7t-pat.api.svc.cscs.ch/cw |
Santis |
The API surface under each endpoint is the same as the corresponding platform deployment.
The API key is passed in the X-API-Key header, and unlike the platform endpoints, the proxy does not require an OAuth2 access token.
curl -s -X GET "https://f7t-pat.api.svc.cscs.ch/hpcp/status/systems" \
-H "X-API-Key: $CSCS_API_KEY"
For calling the proxy from Python, see using a Service Account with pyFirecREST.
Keep your API key secret
The Service Account API key is a credential. Store it in a secret manager or CI/CD variable and never commit it to a repository.
Getting Started¶
Using the Python Interface¶
One way to get started is by using pyFirecREST, a Python package with a collection of wrappers for the different functionalities of FirecREST. This package simplifies the usage of FirecREST by making multiple requests in the background for more complex workflows as well as by refreshing the access token before it expires.
Try FirecREST using pyFirecREST v2
import json
import firecrest as f7t
client_id = "<client_id>"
client_secret = "<client_secret>"
token_uri = "https://auth.cscs.ch/auth/realms/firecrest-clients/protocol/openid-connect/token"
# Setup the client for the specific account
# For instance, for the Alps HPC Platform system Daint:
client = f7t.v2.Firecrest(
firecrest_url="https://api.cscs.ch/hpc/firecrest/v2",
authorization=f7t.ClientCredentialsAuth(client_id, client_secret, token_uri)
)
# Status of the systems, filesystems and schedulers:
print(json.dumps(client.systems(), indent=2))
# Output: information about systems and health status of the infrastructure
# [
# {
# "name": "daint",
# "ssh": { # --> SSH settings
# "host": "daint.alps.cscs.ch",
# "port": 22,
# "maxClients": 100,
# "timeout": {
# "connection": 5,
# "login": 5,
# "commandExecution": 5,
# "idleTimeout": 60,
# "keepAlive": 5
# }
# },
# "scheduler": { # --> Scheduler settings
# "type": "slurm",
# "version": "24.05.4",
# "apiUrl": null,
# "apiVersion": null,
# "timeout": 10
# },
# "servicesHealth": [ # --> Health status of services
# {
# "serviceType": "scheduler",
# "lastChecked": "2025-03-18T23:34:51.167545Z",
# "latency": 0.4725925922393799,
# "healthy": true,
# "message": null,
# "nodes": {
# "available": 21,
# "total": 858
# }
# },
# {
# "serviceType": "ssh",
# "lastChecked": "2025-03-18T23:34:52.054056Z",
# "latency": 1.358715295791626,
# "healthy": true,
# "message": null
# },
# {
# "serviceType": "filesystem",
# "lastChecked": "2025-03-18T23:34:51.969350Z",
# "latency": 1.2738196849822998,
# "healthy": true,
# "message": null,
# "path": "/capstor/scratch/cscs"
# },
# (...)
# "fileSystems": [ # --> Filesystem settings
# {
# "path": "/capstor/scratch/cscs",
# "dataType": "scratch",
# "defaultWorkDir": true
# },
# {
# "path": "/users",
# "dataType": "users",
# "defaultWorkDir": false
# },
# {
# "path": "/capstor/store/cscs",
# "dataType": "store",
# "defaultWorkDir": false
# }
# ]
# }
# ]
# List content of directories
print(json.dumps(client.list_files("daint", "/capstor/scratch/cscs/<username>"),
indent=2))
# [
# {
# "name": "directory",
# "type": "d",
# "linkTarget": null,
# "user": "<username>",
# "group": "<project>",
# "permissions": "rwxr-x---+",
# "lastModified": "2024-09-02T12:34:45",
# "size": "4096"
# },
# {
# "name": "file.txt",
# "type": "-",
# "linkTarget": null,
# "user": "<username>",
# "group": "<project>",
# "permissions": "rw-r-----+",
# "lastModified": "2024-09-02T08:26:04",
# "size": "131225"
# }
# ]
The tutorial is written for a generic instance of FirecREST but if you have a valid user at CSCS you can test it directly with your resource allocation on the exposed systems.
pyFirecREST does not yet natively support the X-API-Key authentication used by Service Account endpoints.
Until it does, the client can be configured with an httpx request hook that replaces the bearer token with the API key header.
Use a Service Account API key with pyFirecREST
The helper below builds a Firecrest client for Service Account access, and the second half of the script uses it to inspect systems, user information and files.
Note that the helper relies on pyFirecREST internals (client._session and create_new_session), so it may need to be adapted after a pyFirecREST upgrade.
import json
import os
import sys
import httpx
from firecrest.v2 import Firecrest
DEFAULT_URL = "https://f7t-pat.api.svc.cscs.ch/hpcp"
API_KEY_HEADER = "X-API-Key"
API_KEY = os.environ.get("CSCS_API_KEY")
if not API_KEY:
print("Set the CSCS_API_KEY environment variable")
sys.exit(1)
class ApiKeyAuth:
"""Placeholder auth object that suppresses token-based authentication."""
def __init__(self, api_key: str):
self.api_key = api_key
def get_access_token(self) -> str:
return "unused-api-key-auth"
def _api_key_hook(api_key: str):
"""Return an httpx request hook that swaps bearer auth for the API key."""
def hook(request: httpx.Request) -> None:
request.headers.pop("Authorization", None)
request.headers[API_KEY_HEADER] = api_key
return hook
def create_client(
api_key: str,
firecrest_url: str = DEFAULT_URL,
) -> Firecrest:
"""Build a ``Firecrest`` client that authenticates with ``X-API-Key``."""
client = Firecrest(
firecrest_url=firecrest_url,
authorization=ApiKeyAuth(api_key),
verify=True,
)
hook = _api_key_hook(api_key)
client._session.event_hooks["request"].append(hook)
# close_session()/create_new_session() build a fresh httpx.Client, which
# would come without our hook, so re-install it on every new session.
original_create_new_session = client.create_new_session
def create_new_session_with_hook() -> None:
original_create_new_session()
client._session.event_hooks["request"].append(hook)
client.create_new_session = create_new_session_with_hook
return client
SYSTEM = "daint"
client = create_client(api_key=API_KEY, firecrest_url=DEFAULT_URL)
#
# using the client
#
print(f"Server version: {client.server_version() or 'unknown'}")
systems = client.systems()
print(f"\nSystems ({len(systems)}):")
for system in systems:
print(f" - {system.get('name')}")
print("\nUser info:")
user = client.userinfo(system_name=SYSTEM)
print(json.dumps(user, indent=2))
print("\nHome directory:")
username = user["user"]["name"]
for entry in client.list_files(system_name=SYSTEM, path=f"/users/{username}"):
print(f" {entry.get('permissions', ''):>10} {entry.get('name')}")
client.close_session()
Data transfer with FirecREST¶
In addition to the external transfer methods at CSCS, FirecREST provides automated data transfer within the API.
A staging area is used for external transfers and downloading/uploading a file from/to a CSCS filesystem.
Note
pyFirecREST hides this complexity to the user. We strongly recommend to use this library for these tasks.
Examples of data transfer via pyFirecREST¶
Upload a large file using FirecREST-v2
import firecrest as f7t
(...)
system = "daint"
source_path = "/path/to/local/file"
target_dir = "/capstor/scratch/cscs/<username>"
target_file = "file"
account = "<project>"
upload_task = client.upload(system,
local_file=source_path,
directory=target_dir,
filename=target_file,
account=account,
blocking=True)
Download a large file using FirecREST-v2
Job submission through FirecREST
FirecREST provides an abstraction for job submission using in the backend the Slurm scheduler of the vCluster.
When submitting a job via the different endpoints, you should pass the -l option to the /bin/bash command on the batch file.
This option ensures that the job submitted uses the same environment as your login shell to access the system-wide profile (/etc/profile) or to your profile (in files like ~/.bash_profile, ~/.bash_login, or ~/.profile).