Uploads¶
NomadUpload
¶
Represents an upload in the NOMAD system, encapsulating all relevant metadata and state information.
Attributes:
Name | Type | Description |
---|---|---|
upload_id |
str
|
Unique identifier for the upload. |
upload_create_time |
datetime
|
The creation time of the upload. |
main_author |
NomadUser
|
The main author of the upload. |
process_running |
bool
|
Flag indicating if a process is currently running for this upload. |
current_process |
str
|
The name of the current process running. |
process_status |
str
|
The status of the current process. |
last_status_message |
str
|
The last status message received for the current process. |
errors |
list[Any]
|
A list of errors associated with the upload. |
warnings |
list[Any]
|
A list of warnings associated with the upload. |
coauthors |
list[str]
|
List of coauthor identifiers. |
coauthor_groups |
list[Any]
|
List of coauthor groups. |
reviewers |
list[NomadUser]
|
List of reviewers. |
reviewer_groups |
list[Any]
|
List of reviewer groups. |
writers |
list[NomadUser]
|
List of writers with access to the upload. |
writer_groups |
list[Any]
|
List of writer groups. |
viewers |
list[NomadUser]
|
List of viewers with access to the upload. |
viewer_groups |
list[Any]
|
List of viewer groups. |
published |
bool
|
Flag indicating if the upload is published. |
published_to |
list[Any]
|
List of platforms or locations the upload is published to. |
with_embargo |
bool
|
Flag indicating if the upload is under embargo. |
embargo_length |
float
|
The length of the embargo in days. |
license |
str
|
The license associated with the upload. |
entries |
int
|
The number of entries in the upload. |
n_entries |
Optional[int]
|
The number of entries, if known. |
upload_files_server_path |
Optional[str]
|
The server path to the uploaded files. |
publish_time |
Optional[datetime]
|
The time the upload was published. |
references |
Optional[list[str]]
|
List of references associated with the upload. |
datasets |
Optional[list[str]]
|
List of dataset identifiers associated with the upload. |
external_db |
Optional[str]
|
External database identifier. |
upload_name |
Optional[str]
|
The name of the upload. |
comment |
Optional[str]
|
A comment or description of the upload. |
use_prod |
Optional[bool]
|
Flag indicating if the production environment is used. |
complete_time |
Optional[datetime]
|
The time the upload was completed. |
Source code in martignac/nomad/uploads.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
delete_file_to_specified_path(upload_id, remote_path, local_file, use_prod=False, timeout_in_sec=10)
¶
Deletes a file from a specific path within an upload in the NOMAD system.
This function deletes a specified file from a specific path within an existing upload in the NOMAD system. It allows the user to choose between the production and test environments. It also supports setting a custom timeout for the deletion process to prevent indefinite waiting periods. The function logs the outcome of the deletion process, including success or failure messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload from which the file should be deleted. |
required |
path |
str
|
The path where the file should be deleted within the upload. |
required |
file |
The file to the file to be deleted. |
required | |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for the deletion to complete. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the response from the NOMAD system regarding the deletion action. |
Source code in martignac/nomad/uploads.py
delete_upload(upload_id, use_prod=False, timeout_in_sec=10)
¶
Deletes a specific upload from the NOMAD system based on its unique ID.
This function sends a request to the NOMAD system to delete an upload identified by its unique ID. It allows specifying whether to interact with the production or test environment of the NOMAD system. Additionally, a timeout for the network request can be defined to avoid indefinite waiting periods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload to be deleted. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
NomadUpload |
NomadUpload
|
An instance of |
Raises:
Type | Description |
---|---|
ValueError
|
If the deletion request fails or the response from the NOMAD system is unexpected. |
Source code in martignac/nomad/uploads.py
edit_upload_metadata(upload_id, upload_name=None, references=None, dataset_id=None, embargo_length=None, coauthors_ids=None, comment=None, use_prod=False, timeout_in_sec=10)
¶
Edits the metadata of a specific upload in the NOMAD system.
This function allows for the modification of various metadata fields of an existing upload, identified by its unique ID. It supports updating the upload's name, references, dataset ID, embargo length, coauthors, and additional comments. The function also allows specifying whether to interact with the production or test environment of the NOMAD system, along with a custom timeout for the network request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload to be edited. |
required |
upload_name |
Optional[str]
|
The new name for the upload. |
None
|
references |
Optional[list[str]]
|
A list of new references associated with the upload. |
None
|
dataset_id |
Optional[str]
|
The new dataset ID associated with the upload. |
None
|
embargo_length |
Optional[float]
|
The new embargo length in days. |
None
|
coauthors_ids |
Optional[list[str]]
|
A list of new coauthor identifiers. |
None
|
comment |
Optional[str]
|
A new comment or description for the upload. |
None
|
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the response from the NOMAD system regarding the edit action. |
Source code in martignac/nomad/uploads.py
get_all_my_uploads(use_prod=False, timeout_in_sec=10)
¶
Retrieves all uploads associated with the authenticated user from the NOMAD system.
This function fetches a list of all uploads made by the currently authenticated user. It allows the user to specify whether to interact with the production or test environment of the NOMAD system. The function also supports specifying a timeout for the network request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Type | Description |
---|---|
list[NomadUpload]
|
list[NomadUpload]: A list of |
Source code in martignac/nomad/uploads.py
get_specific_file_from_upload(upload_id, path_to_file, use_prod=False, with_authentication=False, return_json=True, timeout_in_sec=10)
¶
Downloads a file associated with a specific upload from the NOMAD system.
This function retrieves a file associated with a specific upload from the NOMAD system and saves it to the specified path on the local filesystem. It allows specifying whether to interact with the production or test environment of the NOMAD system. Additionally, a timeout for the network request can be defined to manage how long the function waits for the file to be downloaded.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload containing the file to download. |
required |
path_to_file |
str
|
The path where the downloaded file should be saved on the local filesystem. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
with_authentication |
bool
|
Flag indicating whether to include authentication headers in the request. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for the file to be downloaded. Defaults to 10 seconds. |
10
|
return_json |
bool
|
Flag indicating whether to return the response as JSON or as a byte string. |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file cannot be downloaded or saved to the specified path. |
Source code in martignac/nomad/uploads.py
get_upload_by_id(upload_id, use_prod=False, with_authentication=True, timeout_in_sec=10)
¶
Retrieves a specific upload by its ID from the NOMAD system.
This function fetches the details of a single upload identified by its unique ID. It allows specifying whether to access the production or test environment of the NOMAD system. Additionally, a timeout for the network request can be defined.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload to retrieve. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
with_authentication |
bool
|
Flag indicating whether to include authentication headers in the request. |
True
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
NomadUpload |
NomadUpload
|
An instance of |
Source code in martignac/nomad/uploads.py
publish_upload(upload_id, use_prod=False, timeout_in_sec=10)
¶
Publishes a specified upload in the NOMAD system.
This function sends a request to the NOMAD system to publish an upload identified by its unique ID. It allows specifying whether to interact with the production or test environment of the NOMAD system. Additionally, a timeout for the network request can be defined to manage how long the function waits for a response from the NOMAD system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload to be published. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the response from the NOMAD system regarding the publish action. |
Source code in martignac/nomad/uploads.py
upload_file_to_specified_path(upload_id, remote_path, local_file, use_prod=False, timeout_in_sec=10)
¶
Uploads a file to a specific path within an upload in the NOMAD system.
This function uploads a specified file to a specific path within an existing upload in the NOMAD system. It allows the user to choose between the production and test environments. It also supports setting a custom timeout for the upload process to prevent indefinite waiting periods. The function logs the outcome of the upload process, including success or failure messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_id |
str
|
The unique identifier of the upload to which the file should be uploaded. |
required |
path |
str
|
The path where the file should be saved within the upload. |
required |
file |
The file to the file to be uploaded. |
required | |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for the upload to complete. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the response from the NOMAD system regarding the upload action. |
Source code in martignac/nomad/uploads.py
upload_files_to_nomad(filename, use_prod=False, timeout_in_sec=30)
¶
Uploads a file to the NOMAD system.
This function uploads a specified file to the NOMAD system, allowing the user to choose between the production and test environments. It also supports setting a custom timeout for the upload process to prevent indefinite waiting periods. The function logs the outcome of the upload process, including success or failure messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path to the file to be uploaded. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to False, which means the test environment is used by default. |
False
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for the upload to complete. Defaults to 30 seconds. |
30
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The unique identifier of the upload if successful, otherwise logs an error. |
Raises:
Type | Description |
---|---|
IOError
|
If the file cannot be opened or read. |
ValueError
|
If the response from the NOMAD system does not contain an upload ID. |