From 393ae01061642db862eb0f7816129346b0fef9ac Mon Sep 17 00:00:00 2001 From: Joseph Rudzinski Date: Thu, 1 Oct 2026 13:52:51 +0200 Subject: [PATCH 1/2] add waiting helper function --- docs/tutorial/upload_publish_api.md | 45 +++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/docs/tutorial/upload_publish_api.md b/docs/tutorial/upload_publish_api.md index fefddf0aa..88cb49b68 100644 --- a/docs/tutorial/upload_publish_api.md +++ b/docs/tutorial/upload_publish_api.md @@ -302,9 +302,26 @@ This snippet creates a new project for the DFT ZIP file and prints a direct GUI To check whether entries were created, retrieve them, and print their IDs and URLs, you can type the following: +Processing happens in the background. Define this helper to wait up to ten minutes for it to finish; you can reuse it for the XPS upload and publication below. + +```python +import time + +def wait_for_process(upload_id, url='test', timeout_in_sec=600): + deadline = time.monotonic() + timeout_in_sec + while time.monotonic() < deadline: + upload = get_upload_by_id(upload_id=upload_id, url=url) + if not upload.process_running: + return upload + time.sleep(5) + raise TimeoutError(f'NOMAD did not finish processing within {timeout_in_sec} seconds.') +``` + ```python from nomad_utility_workflows.utils.entries import get_entries_of_upload +wait_for_process(upload_id=dft_upload_id, url='test') + dft_entries = get_entries_of_upload( upload_id=dft_upload_id, url='test', with_authentication=True ) @@ -324,7 +341,7 @@ This snippet retrieves all the entries (here only one entry) created from the up ``` !!! warning - If NOMAD is still processing the project, the list may be empty, or the call may fail with `KeyError: 'entry_metadata'`. Wait until processing has finished and run the cell again. `get_entries_of_upload` keeps its result for up to three minutes, so an empty list may be repeated until then. + If `wait_for_process` times out, inspect the project in the GUI before retrying. Do not query entries while processing is ongoing because an empty result may be cached for up to three minutes. @@ -347,7 +364,6 @@ The steps are similar to those you followed for the computations data. Here is a ready-to-paste snippet for your Jupyter notebook: ```python import os - import time from nomad_utility_workflows.utils.uploads import ( upload_files_to_nomad, get_upload_by_id, @@ -360,9 +376,7 @@ The steps are similar to those you followed for the computations data. xps_upload = get_upload_by_id(xps_upload_id, url='test') print('Upload GUI URL:', f'{nomad_gui}/projects/{xps_upload.upload_id}') - # wait until NOMAD has finished processing the project - while get_upload_by_id(xps_upload_id, url='test').process_running: - time.sleep(5) + wait_for_process(upload_id=xps_upload_id, url='test') xps_entries = get_entries_of_upload( upload_id=xps_upload_id, url='test', with_authentication=True @@ -686,6 +700,25 @@ pprint(response) 'upload_id': 'dcvqjWYgSZeDVLaJkL6E7w'} ``` -This code triggers the publication action for the DFT project and prints the server response confirming the operation. +The response confirms that the publication request was accepted, not that publication succeeded. Publication runs asynchronously, so wait for it to finish and inspect its final status in a separate cell: + +```python +published_upload = wait_for_process(upload_id=dft_upload_id, url='test') +print('Process status:', published_upload.process_status) +print('Published:', published_upload.published) +print('Errors:', published_upload.errors) +print('Warnings:', published_upload.warnings) +``` + +??? success "Final publication status" + + ``` + Process status: SUCCESS + Published: True + Errors: [] + Warnings: [] + ``` + +Confirm that the process status is `SUCCESS`, `Published` is `True`, and `Errors` is empty; review any warnings as well. For details, see [Inspect a project](#inspect-a-project). From 6fa4317e472b2d24d370585f3c1993afba6f51c7 Mon Sep 17 00:00:00 2001 From: Joseph Rudzinski Date: Thu, 1 Oct 2026 13:55:35 +0200 Subject: [PATCH 2/2] anonymize author ids --- docs/tutorial/upload_publish_api.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/tutorial/upload_publish_api.md b/docs/tutorial/upload_publish_api.md index 88cb49b68..0c4f94ee5 100644 --- a/docs/tutorial/upload_publish_api.md +++ b/docs/tutorial/upload_publish_api.md @@ -517,14 +517,14 @@ edit_upload_metadata( 'upload_id': 'dcvqjWYgSZeDVLaJkL6E7w', 'upload_name': 'NOMAD Tutorial, Prepare DFT example for sharing using API', 'upload_create_time': '2026-09-29T09:47:05.108000Z', - 'main_author': 'f250f5ab-b05c-4bad-9939-5f4883c7a694', + 'main_author': '00000000-0000-4000-8000-000000000001', 'coauthors': [], 'coauthor_groups': [], 'reviewers': [], 'reviewer_groups': [], - 'writers': ['f250f5ab-b05c-4bad-9939-5f4883c7a694'], + 'writers': ['00000000-0000-4000-8000-000000000001'], 'writer_groups': [], - 'viewers': ['f250f5ab-b05c-4bad-9939-5f4883c7a694'], + 'viewers': ['00000000-0000-4000-8000-000000000001'], 'viewer_groups': [], 'published': False, 'published_to': [], @@ -591,8 +591,8 @@ for user in candidates: ??? success "Example notebook output" ``` - Found the user 'Jane Doe' (username 'jane.doe') with user_id='13b845c3-e48d-4234-8c51-4f88c6897ac8' - Found the user 'Jane Doe' (username 'jane.doe@example.org') with user_id='ebb26223-0cec-4d81-98f5-3b25db945b54' + Found the user 'Jane Doe' (username 'jane.doe') with user_id='00000000-0000-4000-8000-000000000002' + Found the user 'Jane Doe' (username 'jane.doe@example.org') with user_id='00000000-0000-4000-8000-000000000003' ``` If several users have the same name, use the username to pick the right one. @@ -669,7 +669,7 @@ pprint(response) ``` {'data': {'coauthor_groups': [], - 'coauthors': ['ebb26223-0cec-4d81-98f5-3b25db945b54'], + 'coauthors': ['00000000-0000-4000-8000-000000000003'], 'complete_time': '2026-09-29T11:18:29.488000Z', 'current_process': '_publish_upload', 'embargo_length': 3, @@ -677,7 +677,7 @@ pprint(response) 'errors': [], 'last_status_message': 'Process completed successfully', 'license': 'CC BY 4.0', - 'main_author': 'f250f5ab-b05c-4bad-9939-5f4883c7a694', + 'main_author': '00000000-0000-4000-8000-000000000001', 'process_running': True, 'process_status': 'PENDING', 'published': False, @@ -690,13 +690,13 @@ pprint(response) 'upload_name': 'NOMAD Tutorial, Prepare DFT example for sharing ' 'using API', 'viewer_groups': [], - 'viewers': ['f250f5ab-b05c-4bad-9939-5f4883c7a694', - 'ebb26223-0cec-4d81-98f5-3b25db945b54'], + 'viewers': ['00000000-0000-4000-8000-000000000001', + '00000000-0000-4000-8000-000000000003'], 'warnings': [], 'with_embargo': True, 'writer_groups': [], - 'writers': ['f250f5ab-b05c-4bad-9939-5f4883c7a694', - 'ebb26223-0cec-4d81-98f5-3b25db945b54']}, + 'writers': ['00000000-0000-4000-8000-000000000001', + '00000000-0000-4000-8000-000000000003']}, 'upload_id': 'dcvqjWYgSZeDVLaJkL6E7w'} ```