Skip to content

Commit f595fc8

Browse files
authored
add f7t docs (#26)
1 parent b1ba08d commit f595fc8

File tree

9 files changed

+241
-0
lines changed

9 files changed

+241
-0
lines changed
67.9 KB
Loading
135 KB
Loading

docs/images/firecrest/f7t-apis.png

110 KB
Loading
47.6 KB
Loading
61 KB
Loading
88.2 KB
Loading

docs/images/firecrest/f7t-keys.png

42.2 KB
Loading

docs/tools/firecrest.md

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
# FirecREST
2+
3+
FirecREST is a RESTful API for managing High-Performance Computing resources, developed at CSCS.
4+
Scientific platform developers can integrate Firecrest into web-enabled portals and applications, allowing them to securely access authenticated and authorized CSCS services such as job submission and data transfer on HPC systems.
5+
6+
Users can make HTTP requests to perform the following operations:
7+
8+
* basic system utilities like `ls`, `mkdir`, `mv`, `chmod`, `chown`, among others
9+
* actions against the Slurm workload manager (submit, query, and cancel jobs of the user)
10+
* internal (between CSCS systems) and external (to/from CSCS systems) data transfers
11+
12+
For a full feature set, have a look at the latest [FirecREST API specification](https://firecrest-docs.v1.svc.cscs.ch/) deployed at CSCS.
13+
14+
Please refer to the [FirecREST documentation](https://firecrest.readthedocs.io/en/latest/) for detailed documentation.
15+
16+
## FirecREST Deployment on Alps
17+
18+
FirecREST is available for all three major [Alps platforms][ref-alps-platforms], with a different API endpoint for each platform.
19+
20+
| Platform | API Endpoint | Clusters |
21+
|----------|-------------|-----------|
22+
| HPC Platform | https://api.cscs.ch/hpc/firecrest/v1 | [Daint][ref-cluster-daint], [Eiger][ref-cluster-eiger] |
23+
| ML Platform | https://api.cscs.ch/ml/firecrest/v1 | [Bristen][ref-cluster-bristen], [Clariden][ref-cluster-clariden] |
24+
| CW Platform | https://api.cscs.ch/cw/firecrest/v1 | [Santis][ref-cluster-santis] |
25+
26+
## Developer Portal: Creating FirecREST clients
27+
28+
The [Developer Portal](https://developer.cscs.ch) is an application based on [WSO2 API Manager](https://wso2.com/api-manager/) that facilitates CSCS Users to manage subscriptions to an API at CSCS (such as FirecREST).
29+
30+
Start by navigating to [developer.cscs.ch](https://developer.cscs.ch), then sign in by clicking the "SIGN-IN" button on the top right hand corner of the page.
31+
32+
Once logged in, you will see a list of APIs that are available to your user.
33+
34+
### Creating an Application
35+
36+
Click on the "Applications" button at the top of the screen to manage your Applications.
37+
38+
![FirecREST Main Page](../images/firecrest/f7t-apis.png)
39+
40+
To create a new application, click on the "ADD NEW APPLICATION" button at the top of the Applications page, and complete the mandatory fields (marked with `*`).
41+
Make sure to give the application a unique name and select the number of requests per minute.
42+
When finished, click on the "Save" button.
43+
44+
!!! note
45+
To subscribe to an API you need at least one application, for which it is possible to use the DefaultApplication.
46+
47+
!!! note
48+
The quota of requests per minute will be shared by all subscribers to the Application over all APIs.
49+
50+
### Configuring Production Keys
51+
52+
53+
Once the Application is created, create the Production Keys (Client ID and Client Secret) by clicking on "Production Keys"
54+
55+
![FirecREST production keys](../images/firecrest/f7t-keys.png)
56+
57+
There are two ways to configuring production keys:
58+
59+
=== "use existing OAuth keys"
60+
61+
This approach can be used if you have already generated keys for FirecREST.
62+
63+
* click on the "Provide Existing OAuth Keys" button
64+
* enter the Consumer Key (Client ID) and Consumer Secret (Client Secret)
65+
* click the "Provide" button to confirm
66+
67+
![FirecREST existing keys](../images/firecrest/f7t-existing-keys.png)
68+
69+
=== "generate new OAuth keys"
70+
71+
Use this if this is your first FirecREST application, or if you wish to create new keys.
72+
73+
* click on the "Generate Keys" button at the bottom of the page
74+
75+
![FirecREST existing keys](../images/firecrest/f7t-generate-keys.png)
76+
77+
Once the keys are generated, you will see the pair "Consumer Key" and "Consumer Secret".
78+
79+
![FirecREST keys](../images/firecrest/f7t-keys-overview.png)
80+
81+
!!! warning
82+
Store this pair of credentials securely, these are the access keys to your resources at CSCS.
83+
84+
### Subscribe to an API
85+
86+
Once you have set up your Application, is time to subscribe it to an API.
87+
88+
To do so:
89+
90+
* (8a) click on the "Subscriptions" option on the left panel
91+
* (8b) click the :fontawesome-solid-circle-plus: "Subscribe APIS" button
92+
* (8c) choose the API you want to subscribe to by clicking the "Subscribe" button
93+
94+
![FirecREST subscriptions](../images/firecrest/f7t-api-subscriptions.png)
95+
96+
Back on the Subscription Management page, you can review your active subscriptions and APIs that your Application has access to.
97+
98+
![FirecREST subscription management](../images/firecrest/f7t-api-subscriptions-management.png)
99+
100+
To use your Application to access FirecREST, follow the [API documentation](https://firecrest-docs.v1.svc.cscs.ch/).
101+
102+
## Getting Started
103+
104+
### Using the Python Interface
105+
106+
One way to get started is by using [pyFirecREST](https://pyfirecrest.readthedocs.io/), a Python package with a collection of wrappers for the different functionalities of FirecREST.
107+
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.
108+
109+
110+
!!! example "Try FirecREST using pyFirecREST"
111+
```python
112+
import firecrest as fc
113+
114+
115+
client_id = <client_id>
116+
client_secret = <client_secret>
117+
token_uri = "https://auth.cscs.ch/auth/realms/firecrest-clients/protocol/openid-connect/token"
118+
119+
# Setup the client for the specific account
120+
# For instance, for the Alps HPC Platform system Daint:
121+
122+
client = fc.Firecrest(
123+
firecrest_url="https://api.cscs.ch/hpc/firecrest/v1",
124+
authorization=fc.ClientCredentialsAuth(client_id, client_secret, token_uri)
125+
)
126+
127+
print(client.all_systems())
128+
# Output: (one dictionary per system)
129+
# [{
130+
# 'system': 'daint'
131+
# 'status': 'available',
132+
# 'description': 'System ready',
133+
# }]
134+
135+
print(client.list_files('daint', '/capstor/scratch/cscs/<username>'))
136+
# Example output: (one dictionary per file)
137+
# [{
138+
# 'name': 'file.txt',
139+
# 'user': 'username'
140+
# 'last_modified': '2024-04-28T12:03:33',
141+
# 'permissions': 'rw-r--r--',
142+
# 'size': '2021',
143+
# 'type': '-',
144+
# 'group': 'project',
145+
# 'link_target': '',
146+
# },
147+
# {
148+
# 'name': 'test-dir',
149+
# 'user': 'username'
150+
# 'last_modified': '2024-04-20T11:22:41',
151+
# 'permissions': 'rwxr-xr-x',
152+
# 'size': '4096',
153+
# 'type': 'd',
154+
# 'group': 'project',
155+
# 'link_target': '',
156+
# }]
157+
```
158+
159+
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.
160+
161+
### CSCS Developer Portal
162+
163+
A client application that makes requests to FirecREST will not be using directly the credentials of the user for the authentication, but an access token instead. The access token is a signed JSON Web Token (JWT) which contains expiry information. Behind the API, all commands launched by the client will use the account of the user that registered the client, inheriting their access rights. You can manage your client application on the CSCS Developer Portal.
164+
165+
Every client will have a client ID (Consumer Key) and a secret (Consumer Secret) that will be used to get a short-lived access token with an HTTP request.
166+
167+
!!! example "curl call to fetch the access token"
168+
```
169+
curl -s -X POST https://auth.cscs.ch/auth/realms/firecrest-clients/protocol/openid-connect/token \
170+
--data "grant_type=client_credentials" \
171+
--data "client_id=<your_client>" \
172+
--data "client_secret=<your_secret>"
173+
```
174+
175+
### Downloading Large Files
176+
177+
A staging area is used for external transfers and downloading/uploading a file from/to a CSCS filesystem.
178+
179+
Please follow the steps below to download a file:
180+
181+
1. Request FirecREST to move the file to the staging area: a download link will be provided
182+
2. The file will remain in the staging area for 7 days or until the link gets invalidated with a request to the [`/storage/xfer-external/invalidate`](https://firecrest.readthedocs.io/en/latest/reference.html#post--storage-xfer-external-invalidate) endpoint or through the pyfirecrest method
183+
3. The staging area is common for all users, therefore users should invalidate the link as soon as the download has been completed
184+
185+
You can see the full process in this [tutorial](https://firecrest.readthedocs.io/en/latest/tutorial.html#upload-with-non-blocking-call-something-bigger).
186+
187+
We may be forced to delete older files sooner than 7 days whenever large files are moved to the staging area and the link is not invalidated after the download, to avoid issues for other users: we will contact the user in this case.
188+
189+
When uploading files through the staging area, you don't need to invalidate the link. FirecREST will do it automatically as soon as it transfers the file to the filesystem of CSCS.
190+
191+
There is also a constraint on the size of a single file to transfer externally to our systems via FirecREST: 5 GB.
192+
193+
If you wish to transfer data bigger than the limit mentioned above, you can check the [compress](https://firecrest.readthedocs.io/en/latest/reference.html#post--storage-xfer-internal-compress) and [extract](https://firecrest.readthedocs.io/en/latest/reference.html#post--storage-xfer-internal-extract) endpoints or follow the following [example on how to split large files](https://github.com/eth-cscs/firecrest/blob/master/examples/download-large-files/README.md) and download/upload them using FirecREST.
194+
195+
The limit on the time and size of files that can be download/uploaded via FirecREST might change if needed.
196+
197+
!!! example "checking the current values in the parameters endpoint"
198+
```python
199+
>>> print(json.dumps(client.parameters(), indent = 2))
200+
{
201+
(...)
202+
203+
"storage": [
204+
{
205+
"description": "Type of object storage, like `swift`, `s3v2` or `s3v4`.",
206+
"name": "OBJECT_STORAGE",
207+
"unit": "",
208+
"value": "s3v4"
209+
},
210+
{
211+
"description": "Expiration time for temp URLs.",
212+
"name": "STORAGE_TEMPURL_EXP_TIME",
213+
"unit": "seconds",
214+
"value": "604800" ## <-------- 7 days
215+
},
216+
{
217+
"description": "Maximum file size for temp URLs.",
218+
"name": "STORAGE_MAX_FILE_SIZE",
219+
"unit": "MB",
220+
"value": "5120" ## <--------- 5 GB
221+
}
222+
(...)
223+
}
224+
```
225+
### Job Submission to the Workload Manager through FirecREST
226+
227+
FirecREST provides an abstraction for job submission using in the backend the SLURM scheduler of the vCluster (in the case of CSCS).
228+
229+
When submitting a job via the different [endpoints](https://firecrest.readthedocs.io/en/latest/reference.html#compute), you should pass the `-l` option to the `/bin/bash` command on the batch file.
230+
231+
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`).
232+
233+
## Further Information
234+
235+
* [Full list of FirecREST calls](https://firecrest.readthedocs.io/en/latest/reference.html)
236+
* [Documentation of FirecREST](https://firecrest.readthedocs.io/)
237+
* [Documentation of pyFirecREST](https://pyfirecrest.readthedocs.io/)
238+
* [Demo FirecREST environment in Git](https://github.com/eth-cscs/firecrest/tree/master/deploy/demo)
239+
* [www.oauth.com](https://www.oauth.com)
240+
* [Python Requests](https://requests.readthedocs.io/en/master/user/quickstart)

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ nav:
6969
- 'Tools':
7070
- tools/index.md
7171
- 'slurm': tools/slurm.md
72+
- 'FirecREST': tools/firecrest.md
7273
- 'uenv': tools/uenv.md
7374
- 'Data Management and Storage':
7475
- storage/index.md

0 commit comments

Comments
 (0)