api.py
script is designed to upload XRDML files to the NOMAD. You can change endpoint to your local NOMAD Oasis or to general NOMAD. It provides a simple command-line interface for users to authenticate, select a directory containing XRDML files, and upload the files to the NOMAD Lab API.
- Clone the repository and navigate to the project directory.
- Run the script using
python api.py
. - Enter your NOMAD Lab username and password when prompted.
- Select a directory containing XRDML files to upload.
- Enter the sample name (Load Sample) for the files being uploaded.
- The script will upload the files to the NOMAD and prompt you if you want to upload another set of growth.
- Repeat steps 4-6 until you have uploaded all desired files.
The script uses a YAML configuration file (config.yml
) to store user settings. The configuration file is created automatically when you run the script for the first time.
directory_path
: The path to the directory containing XRDML files to upload.
modify_xrdml(file_path, user_name, sample_id)
: Modifies an XRDML file by updating the author name and sample ID.
authenticate(username, password)
: Authenticates a user with the NOMAD Lab API and retrieves an access token.get_username_me(api_token)
: Retrieves the username of the authenticated user.upload_files(directory_path, token, sample_id)
: Uploads multiple XRDML files from a specified directory to the NOMAD Lab API.upload_file(file_path, token)
: Uploads a single file to the NOMAD Lab API.get_upload_id(token)
: Uploads a file and retrieves its upload ID from the NOMAD Lab API.
get_directory_path(config, username)
: Gets the directory path for file uploads from the user or configuration.
TEST_api_gui
was an attempt to write a GUI program for theapi.py
script. It is abandoned but yet you can use it for basic fucntionalities and it is a proof of concept.TEST_compress.py
was to test the idea to upload the modified*.xrdml
file as main and original*.xrdml
data and other files as a*.7z
zip file.TEST_os_file_time.py
was to test the idea if we can align the time of growth with time the*.xrdml
file is created.