Reference

The wrapper includes the Firecrest class, which is in practice a very basic client. Together with the authorisation class it takes care of the token and makes the appropriate calls for each action.

The Firecrest class

class firecrest.Firecrest(firecrest_url, authorization, verify=None, sa_role='firecrest-sa')

Bases: object

This is the basic class you instantiate to access the FirecREST API v1. Necessary parameters are the firecrest URL and an authorization object. This object is responsible of handling the credentials and the only requirement for it is that it has a method get_access_token() that returns a valid access token.

Parameters
  • firecrest_url (string) – FirecREST’s URL

  • authorization (object) – the authorization object

  • verify (boolean or string, optional) – either a boolean, in which case it controls whether requests will verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use (default True)

  • sa_role (string, optional) – this corresponds to the F7T_AUTH_ROLE configuration parameter of the site. If you don’t know how FirecREST is setup it’s better to leave the default.

all_services()

Returns a list containing all available micro services with a name, description, and status.

Calls

GET /status/services

Return type

list of dictionaries (one for each service)

service(servicename)

Returns information about a micro service. Returns the name, description, and status.

Parameters

servicename (string) – the service name

Calls

GET /status/services/{servicename}

Return type

list of dictionaries (one for each service)

all_systems()

Returns a list containing all available systems and response status.

Calls

GET /status/systems

Return type

list of dictionaries (one for each system)

system(systemname)

Returns information about a system. Returns the name, description, and status.

Parameters

systemname (string) – the system name

Calls

GET /status/systems/{systemname}

Return type

list of dictionaries (one for each system)

parameters()

Returns list of parameters that can be configured in environment files.

Calls

GET /status/parameters

Return type

list of parameters

list_files(machine, targetPath, showhidden=None)

Returns a list of files in a directory.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

  • showhidden (boolean, optional) – show hidden files

Calls

GET /utilities/ls

Return type

list of files

mkdir(machine, targetPath, p=None)

Creates a new directory.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

  • p (boolean, optional) – no error if existing, make parent directories as needed

Calls

POST /utilities/mkdir

Return type

None

mv(machine, sourcePath, targetPath)

Rename/move a file, directory, or symlink at the sourcePath to the targetPath on machine’s filesystem.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string) – the absolute target path

Calls

PUT /utilities/rename

Return type

None

chmod(machine, targetPath, mode)

Changes the file mod bits of a given file according to the specified mode.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

  • mode (string) – same as numeric mode of linux chmod tool

Calls

PUT /utilities/chmod

Return type

None

chown(machine, targetPath, owner=None, group=None)

Changes the user and/or group ownership of a given file. If only owner or group information is passed, only that information will be updated.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

  • owner (string, optional) – owner username for target

  • group (string, optional) – group username for target

Calls

PUT /utilities/chown

Return type

None

copy(machine, sourcePath, targetPath)

Copies file from sourcePath to targetPath.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string) – the absolute target path

Calls

POST /utilities/copy

Return type

None

file_type(machine, targetPath)

Uses the file linux application to determine the type of a file.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

Calls

GET /utilities/file

Return type

string

Creates a symbolic link.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute path that the symlink will point to

  • symlink (string) – the absolute path to the new symlink

Calls

POST /utilities/symlink

Return type

None

simple_download(machine, sourcePath, targetPath)

Blocking call to download a small file. The maximun size of file that is allowed can be found from the parameters() call.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string) – the absolute target path

Calls

GET /utilities/download

Return type

None

simple_upload(machine, sourcePath, targetPath)

Blocking call to upload a small file. The maximum size of file that is allowed can be found from the parameters() call.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string) – the absolute target path

Calls

POST /utilities/upload

Return type

None

simple_delete(machine, targetPath)

Blocking call to delete a small file.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

Calls

DELETE /utilities/rm

Return type

None

checksum(machine, targetPath)

Calculate the SHA256 (256-bit) checksum of a specified file.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

Calls

GET /utilities/checksum

Return type

string

view(machine, targetPath)

View the content of a specified file.

Parameters
  • machine (string) – the machine name where the filesystem belongs to

  • targetPath (string) – the absolute target path

Calls

GET /utilities/checksum

Return type

string

whoami()

Returns the username that FirecREST will be using to perform the other calls. Will return None if the token is not valid.

Return type

string or None

submit(machine, job_script, local_file=True)

Submits a batch script to SLURM on the target system

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • job_script (string) – the path of the script (if it’s local it can be relative path, if it is on the machine it has to be the absolute path)

  • local_file (boolean, optional) – batch file can be local (default) or on the machine’s filesystem

Calls

POST /compute/jobs/upload or POST /compute/jobs/path

GET /tasks/{taskid}

Return type

dictionary

poll(machine, jobs=[], starttime=None, endtime=None)

Retrieves information about submitted jobs. This call uses the sacct command.

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • jobs (list of strings/integers, optional) – list of the IDs of the jobs (default [])

  • starttime (string, optional) – Start time (and/or date) of job’s query. Allowed formats are HH:MM[:SS] [AM|PM] MMDD[YY] or MM/DD[/YY] or MM.DD[.YY] MM/DD[/YY]-HH:MM[:SS] YYYY-MM-DD[THH:MM[:SS]]

  • endtime (string, optional) – End time (and/or date) of job’s query. Allowed formats are HH:MM[:SS] [AM|PM] MMDD[YY] or MM/DD[/YY] or MM.DD[.YY] MM/DD[/YY]-HH:MM[:SS] YYYY-MM-DD[THH:MM[:SS]]

Calls

GET /compute/acct

GET /tasks/{taskid}

Return type

dictionary

cancel(machine, jobid)

Retrieves information about submitted jobs. This call uses the scancel command.

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • jobid (list of strings/integers, optional) – the absolute target path (default [])

Calls

DELETE /compute/jobs/{jobid}

GET /tasks/{taskid}

Return type

dictionary

submit_move_job(machine, sourcePath, targetPath, jobname=None, time=None, stageOutJobId=None, account=None)

Move files between internal CSCS file systems. Rename/Move sourcePath to targetPath. Possible to stage-out jobs providing the SLURM Id of a production job. More info about internal transfer: https://user.cscs.ch/storage/data_transfer/internal_transfer/

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string,) – the absolute target path

  • jobname (string, optional) – job name

  • time (string, optional) – limit on the total run time of the rename. Acceptable time formats ‘minutes’, ‘minutes:seconds’, ‘hours:minutes:seconds’, ‘days-hours’, ‘days-hours:minutes’ and ‘days-hours:minutes:seconds’. Note: for stage-in queue a slurm xfer job.

  • stageOutJobId (string, optional) – transfer data after job with ID {stageOutJobId} is completed

  • account (string, optional) – name of the bank account to be used in SLURM. If not set, system default is taken.

Calls

POST /storage/xfer-internal/mv

GET /tasks/{taskid}

Return type

dictionary with the jobid of the submitted job

submit_copy_job(machine, sourcePath, targetPath, jobname=None, time=None, stageOutJobId=None, account=None)

Copy files between internal CSCS file systems. Copy sourcePath to targetPath. Possible to stage-out jobs providing the SLURM Id of a production job. More info about internal transfer: https://user.cscs.ch/storage/data_transfer/internal_transfer/

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string,) – the absolute target path

  • jobname (string, optional) – job name

  • time (string, optional) – limit on the total run time of the rename. Acceptable time formats ‘minutes’, ‘minutes:seconds’, ‘hours:minutes:seconds’, ‘days-hours’, ‘days-hours:minutes’ and ‘days-hours:minutes:seconds’. Note: for stage-in queue a slurm xfer job.

  • stageOutJobId (string, optional) – transfer data after job with ID {stageOutJobId} is completed

  • account (string, optional) – name of the bank account to be used in SLURM. If not set, system default is taken.

Calls

POST /storage/xfer-internal/cp

GET /tasks/{taskid}

Return type

dictionary with the jobid of the submitted job

submit_rsync_job(machine, sourcePath, targetPath, jobname=None, time=None, stageOutJobId=None, account=None)

Transfer files between internal CSCS file systems. Transfer sourcePath to targetPath. Possible to stage-out jobs providing the SLURM Id of a production job. More info about internal transfer: https://user.cscs.ch/storage/data_transfer/internal_transfer/

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • sourcePath (string) – the absolute source path

  • targetPath (string,) – the absolute target path

  • jobname (string, optional) – job name

  • time (string, optional) – limit on the total run time of the rename. Acceptable time formats ‘minutes’, ‘minutes:seconds’, ‘hours:minutes:seconds’, ‘days-hours’, ‘days-hours:minutes’ and ‘days-hours:minutes:seconds’. Note: for stage-in queue a slurm xfer job.

  • stageOutJobId (string, optional) – transfer data after job with ID {stageOutJobId} is completed

  • account (string, optional) – name of the bank account to be used in SLURM. If not set, system default is taken.

Calls

POST /storage/xfer-internal/rsync

GET /tasks/{taskid}

Return type

dictionary with the jobid of the submitted job

submit_delete_job(machine, targetPath, jobname=None, time=None, stageOutJobId=None, account=None)

Remove files in internal CSCS file systems. Remove file in targetPath. Possible to stage-out jobs providing the SLURM Id of a production job. More info about internal transfer: https://user.cscs.ch/storage/data_transfer/internal_transfer/

Parameters
  • machine (string) – the machine name where the scheduler belongs to

  • targetPath (string,) – the absolute target path

  • jobname (string, optional) – job name

  • time (string, optional) – limit on the total run time of the rename. Acceptable time formats ‘minutes’, ‘minutes:seconds’, ‘hours:minutes:seconds’, ‘days-hours’, ‘days-hours:minutes’ and ‘days-hours:minutes:seconds’. Note: for stage-in queue a slurm xfer job.

  • stageOutJobId (string, optional) – transfer data after job with ID {stageOutJobId} is completed

  • account (string, optional) – name of the bank account to be used in SLURM. If not set, system default is taken.

Calls

POST /storage/xfer-internal/rm

GET /tasks/{taskid}

Return type

dictionary with the jobid of the submitted job

external_upload(machine, sourcePath, targetPath)

Non blocking call for the upload of larger files.

Parameters
  • machine (string) – the machine where the filesystem belongs to

  • sourcePath (string) – the source path in the local filesystem

  • targetPath (string) – the target path in the machine’s filesystem

Returns

an ExternalDownload object

Return type

ExternalDownload

external_download(machine, sourcePath)

Non blocking call for the download of larger files.

Parameters
  • machine (string) – the machine where the filesystem belongs to

  • sourcePath (string) – the source path in the local filesystem

  • targetPath (string) – the target path in the machine’s filesystem

Returns

an ExternalDownload object

Return type

ExternalDownload

all_reservations(machine)

List all active reservations and their status

Parameters

machine (string) – the machine name

Calls

GET /reservations

Return type

list of dictionaries (one for each reservation)

create_reservation(machine, reservation, account, numberOfNodes, nodeType, starttime, endtime)

Creates a new reservation with {reservation} name for a given SLURM groupname

Parameters
  • machine (string) – the machine name

  • reservation (string) – the reservation name

  • account (string) – the account in SLURM to which the reservation is made for

  • numberOfNodes (string) – number of nodes needed for the reservation

  • nodeType (string) – type of node

  • starttime (string) – start time for reservation (YYYY-MM-DDTHH:MM:SS)

  • endtime (string) – end time for reservation (YYYY-MM-DDTHH:MM:SS)

Calls

POST /reservations

Return type

None

update_reservation(machine, reservation, account, numberOfNodes, nodeType, starttime, endtime)

Updates an already created reservation named {reservation}

Parameters
  • machine (string) – the machine name

  • reservation (string) – the reservation name

  • account (string) – the account in SLURM to which the reservation is made for

  • numberOfNodes (string) – number of nodes needed for the reservation

  • nodeType (string) – type of node

  • starttime (string) – start time for reservation (YYYY-MM-DDTHH:MM:SS)

  • endtime (string) – end time for reservation (YYYY-MM-DDTHH:MM:SS)

Calls

PUT /reservations/{reservation}

Return type

None

delete_reservation(machine, reservation)

Deletes an already created reservation named {reservation}

Parameters
  • machine (string) – the machine name

  • reservation (string) – the reservation name

Calls

DELETE /reservations/{reservation}

Return type

None

The ExternalUpload class

class firecrest.ExternalUpload(client, task_id, previous_responses=[])

Bases: firecrest.BasicClient.ExternalStorage

This class handles the external upload from a file.

Tracks the progress of the upload through the status of the associated task. Final states: 114 and 115.

Status

Description

110

Waiting for Form URL from Object Storage to be retrieved

111

Form URL from Object Storage received

112

Object Storage confirms that upload to Object Storage has finished

113

Download from Object Storage to server has started

114

Download from Object Storage to server has finished

115

Download from Object Storage error

Parameters
  • client (Firecrest) – FirecREST client associated with the transfer

  • task_id (string) – FirecrREST task associated with the transfer

finish_upload()

Finish the upload process. This call will upload the file to the staging area. Check with the method status or in_progress to see the status of the transfer. The transfer from the staging area to the systems’s filesystem can take several seconds to start to start.

Return type

None

property client

Returns the client that will be used to get information for the task.

Return type

Firecrest Object

property data

Returns the task information from the latest response.

Calls

GET /tasks/{taskid}

Return type

dictionary

property in_progress

Returns False when the transfer has been completed (succesfully or with errors), otherwise True.

Calls

GET /tasks/{taskid}

Return type

boolean

property object_storage_data

Returns the necessary information for the external transfer. The call is blocking and in cases of large file transfers it might take a long time.

Calls

GET /tasks/{taskid}

Return type

dictionary or string

property status

Returns status of the task that is associated with this transfer.

Calls

GET /tasks/{taskid}

Return type

string

The ExternalDownload class

class firecrest.ExternalDownload(client, task_id, previous_responses=[])

Bases: firecrest.BasicClient.ExternalStorage

This class handles the external download from a file.

Tracks the progress of the download through the status of the associated task. Final states: 117 and 118.

Status

Description

116

Started upload from filesystem to Object Storage

117

Upload from filesystem to Object Storage has finished successfully

118

Upload from filesystem to Object Storage has finished with errors

Parameters
  • client (Firecrest) – FirecREST client associated with the transfer

  • task_id (string) – FirecrREST task associated with the transfer

Invalidate the temporary URL for downloading.

Calls

POST /storage/xfer-external/invalidate

Return type

None

finish_download(targetname)

Finish the download process.

Parameters

targetname (string) – the local path to save the file

Return type

None

property client

Returns the client that will be used to get information for the task.

Return type

Firecrest Object

property data

Returns the task information from the latest response.

Calls

GET /tasks/{taskid}

Return type

dictionary

property in_progress

Returns False when the transfer has been completed (succesfully or with errors), otherwise True.

Calls

GET /tasks/{taskid}

Return type

boolean

property object_storage_data

Returns the necessary information for the external transfer. The call is blocking and in cases of large file transfers it might take a long time.

Calls

GET /tasks/{taskid}

Return type

dictionary or string

property status

Returns status of the task that is associated with this transfer.

Calls

GET /tasks/{taskid}

Return type

string

The ClientCredentialsAuthorization class

class firecrest.ClientCredentialsAuthorization(client_id, client_secret, token_uri, debug=False)

Bases: object

ClientCredentialsAuthorization class. Allows login and control the token validation and refresh workflow for an account in keycloak (grant_type=client_credentials)

Parameters
  • client_id (string) – name of the client as registered in keycloak server

  • client_secret (string) – secret delivered by keycloak administrator at registry

  • token_uri (boolean, optional) – URI of the token request in the keycloak server (https://auth.your-server.com/auth/realms/cscs/protocol/openid-connect/token)

  • debug – activates (de-activates) output of the logs (default is False)

get_access_token()

Returns an access token to be used for accessing resources.

Return type

string

is_token_valid(access_token)

Checks if an access token is still valid

Parameters

access_token (string) – access token to be validated

Return type

boolean

get_kc_tokens()

Returns a new access and refresh token from scratch

Return type

dictionary of {“access_token”: <access_token>}

account_login(func)