SDS Files API | <Client>.sds_files
spectrumx.api.sds_files
API functions specific to files.
Classes:
| Name | Description |
|---|---|
FileUploadMode |
Modes for uploading files to SDS. |
Functions:
| Name | Description |
|---|---|
delete_file |
Deletes a file from SDS by its UUID. |
download_file |
Downloads a file from SDS: metadata and contents (unless skip_contents=True). |
get_file |
Get a file instance by its ID. Only metadata is downloaded from SDS. |
list_files |
Lists files in a given SDS path. |
upload_file |
Uploads a file to SDS. |
Classes
FileUploadMode
Bases: Enum
flowchart TD
spectrumx.api.sds_files.FileUploadMode[FileUploadMode]
click spectrumx.api.sds_files.FileUploadMode href "" "spectrumx.api.sds_files.FileUploadMode"
Modes for uploading files to SDS.
Functions
delete_file
delete_file(client: Client, file_uuid: UUID4 | str) -> bool
Deletes a file from SDS by its UUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
The client instance. |
required |
file_uuid
|
UUID4 | str
|
The UUID of the file to delete. |
required |
Returns: True if the file was deleted successfully, or if in dry run mode (simulating success). Raises: SDSError: If the file couldn't be deleted.
Source code in spectrumx/api/sds_files.py
download_file
download_file(
*,
client: Client,
file_instance: File | None = None,
file_uuid: UUID4 | str | None = None,
to_local_path: Path | str | None = None,
skip_contents: bool = False,
warn_missing_path: bool = True,
) -> File
Downloads a file from SDS: metadata and contents (unless skip_contents=True).
Note this function always overwrites the local path of the file instance.
Source code in spectrumx/api/sds_files.py
get_file
Get a file instance by its ID. Only metadata is downloaded from SDS.
Note this does not download the file contents from the server. File
instances still need to have their contents downloaded to create
a local copy - see download_file().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID4 | str
|
The UUID of the file to retrieve. |
required |
Returns: The file instance, or a sample file if in dry run mode.
Source code in spectrumx/api/sds_files.py
list_files
list_files(
*,
client: Client,
sds_path: PurePosixPath | Path | str,
verbose: bool = False,
) -> Paginator[File]
Lists files in a given SDS path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sds_path
|
PurePosixPath | Path | str
|
The virtual directory on SDS to list files from. |
required |
Returns: A paginator for the files in the given SDS path.
Source code in spectrumx/api/sds_files.py
upload_file
upload_file(
*,
client: Client,
local_file: File | Path | str,
sds_path: PurePosixPath | Path | str = "/",
) -> File
Uploads a file to SDS.
If the file instance passed already has a directory set, sds_path will
be prepended. E.g. given:
sds_path = 'baz'; and
local_file.directory = 'foo/bar/', then:
The file will be uploaded to baz/foo/bar/ (under the user root in SDS) and
the returned file instance will have its directory attribute updated
to match this new path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_file
|
File | Path | str
|
The local file to upload. |
required |
sds_path
|
PurePosixPath | Path | str
|
The virtual directory on SDS to upload the file to. |
'/'
|
Returns: The file instance with updated attributes, or a sample when in dry run.