ExportRequest#

class drms.ExportRequest(d, client)[source]#

Bases: object

Class for handling data export requests.

Use Client.export() or Client.export_from_id() to create an instance.

Attributes Summary

data

(pandas.DataFrame) Records and filenames of the export request.

dir

(string) Common directory of the requested files on the server.

id

(string) Request ID.

keywords

(string) Filename of textfile containing record keywords.

method

(string) Export method.

protocol

(string) Export protocol.

request_url

(string) URL of the export request.

status

(int) Export request status.

tarfile

(string) Filename, if a TAR file was requested.

urls

(pandas.DataFrame) URLs of all downloadable files.

Methods Summary

download(directory, *[, index, fname_from_rec])

Download data files.

has_failed(*[, skip_update])

Check if the export request has finished unsuccessfully.

has_finished(*[, skip_update])

Check if the export request has finished.

has_succeeded(*[, skip_update])

Check if the export request has finished successfully.

wait(*[, timeout, sleep, retries_notfound])

Wait for the server to process the export request.

Attributes Documentation

data#

(pandas.DataFrame) Records and filenames of the export request.

Returns a pandas.DataFrame containing the records and filenames of the export request (DataFrame columns: ‘record’, ‘filename’).

dir#

(string) Common directory of the requested files on the server.

id#

(string) Request ID.

keywords#

(string) Filename of textfile containing record keywords.

method#

(string) Export method.

protocol#

(string) Export protocol.

request_url#

(string) URL of the export request.

status#

(int) Export request status.

tarfile#

(string) Filename, if a TAR file was requested.

urls#

(pandas.DataFrame) URLs of all downloadable files.

Returns a pandas.DataFrame containing the records, filenames and URLs of the export request (DataFrame columns: ‘record’, ‘filename’ and ‘url’).

Methods Documentation

download(directory, *, index=None, fname_from_rec=None)[source]#

Download data files.

By default, the server-side filenames are used as local filenames, except for export method ‘url_quick’, where the local filenames are generated from record names (see parameter fname_from_rec). In case a file with the same name already exists in the download directory, an ascending number is appended to the filename.

Note: Downloading data segments that are directories, e.g. data segments from series like “hmi.rdVflows_fd15_frame”, is currently not supported. In order to download data from series like this, you need to use the export method ‘url-tar’ when submitting the data export request.

Parameters:
  • directory (str) – Download directory (must already exist).

  • index (int, List[int], None) – Index (or indices) of the file(s) to be downloaded. If set to None (the default), all files of the export request are downloaded. Note that this parameter is ignored for export method ‘url-tar’, where only a single tar file is available for download.

  • fname_from_rec (bool or None) – If True, local filenames are generated from record names. If set to False, the original filenames are used. If set to None (default), local filenames are generated only for export method ‘url_quick’. Exceptions: For exports with method ‘url-tar’, no filename will be generated. This also applies to movie files from exports with protocols ‘mpg’ or ‘mp4’, where the original filename is used locally.

Returns:

result – DataFrame containing the record string, download URL and local location of each downloaded file (DataFrame columns: ‘record’, ‘url’ and ‘download’).

Return type:

pandas.DataFrame

has_failed(*, skip_update=False)[source]#

Check if the export request has finished unsuccessfully.

Parameters:

skip_update (bool) – If set to True, the export status will not be updated from the server, even if it was in pending state after the last status update.

Returns:

result – True if the export request has finished unsuccessfully or False if the request has succeeded or is still pending.

Return type:

bool

has_finished(*, skip_update=False)[source]#

Check if the export request has finished.

Parameters:

skip_update (bool) – If set to True, the export status will not be updated from the server, even if it was in pending state after the last status update.

Returns:

result – True if the export request has finished or False if the request is still pending.

Return type:

bool

has_succeeded(*, skip_update=False)[source]#

Check if the export request has finished successfully.

Parameters:

skip_update (bool) – If set to True, the export status will not be updated from the server, even if it was in pending state after the last status update.

Returns:

result – True if the export request has finished successfully or False if the request failed or is still pending.

Return type:

bool

wait(*, timeout=None, sleep=5, retries_notfound=5)[source]#

Wait for the server to process the export request. This method continuously updates the request status until the server signals that the export request has succeeded or failed.

Parameters:
  • timeout (int or None) – Maximum number of seconds until this method times out. If set to None (the default), the status will be updated indefinitely until the request succeeded or failed.

  • sleep (int or None) – Time in seconds between status updates (defaults to 5 seconds). If set to None, a server supplied value is used.

  • retries_notfound (int) – Number of retries in case the request was not found on the server. Note that it usually takes a short time until a new request is registered on the server, so a value too low might cause an exception to be raised, even if the request is valid and will eventually show up on the server.

Returns:

result – True if the request succeeded or False if a timeout occurred. In case of an error an exception is raised.

Return type:

bool