Repository navigation
Update the API upload and publish tutorial for GUI v2 projects - #379
Conversation
|
JFRudzinski
left a comment
There was a problem hiding this comment.
Nice work @siamakn , thanks for addressing this one. We are in a bit of an awkward transition phase. Many of the comments can be deferred to follow-up work by creating issues (here and in the utility repo)
I think most importantly we need to see about using this backend url, I am not sure how safe this is
| ## Environment setup | ||
|
|
||
| In this tutorial, we will use the [NOMAD test deployment](https://nomad-lab.eu/prod/v1/test/gui/search/entries){:target="_blank" rel="noopener"}. Therefore, in all code examples, we will set `url="test"` when calling the helper functions. Later, you can switch to `url="prod"` or a custom NOMAD API URL if needed. | ||
| In this tutorial, we will use the [NOMAD test deployment](https://nomad-lab.eu/test/){:target="_blank" rel="noopener"}. Therefore, in all code examples, we will set `url="test"` when calling the helper functions. Later, you can switch to `url="prod"` or a custom NOMAD API URL if needed. When you switch to `url="prod"`, also set `nomad_gui`, defined in [Create projects](#create-projects), to `https://nomad-lab.eu/prod/v1/gui/v2`. |
There was a problem hiding this comment.
it doesn't really make sense to link to a section further down the page. Probably it makes more sense to create a section towards the end called something like "using the production server" and then list all adjustments when you go beyond simply testing
There was a problem hiding this comment.
Also, these gui addresses should (eventually) be added to the nomad-utility-workflows package ... it would be great if you could open an issue there
There was a problem hiding this comment.
Yes, opened FAIRmat-NFDI/nomad-utility-workflows#55.
There was a problem hiding this comment.
After concluding the modifications, I removed the link. Since the settings now sit together in the environment setup, I listed the changes for production below them. Please check and see if moving to a section at the end is a better solution.
| # Upload and publish data using the NOMAD API | ||
|
|
||
| In this tutorial, we interact with the NOMAD API using Python and the [`nomad-utility-workflows`](https://fairmat-nfdi.github.io/nomad-utility-workflows/){:target="_blank" rel="noopener"} package, to programmatically perform the full data upload and publishing workflow. We work with example data files to inspect generated entries, modify metadata, organize entries into datasets, and publish the results on the NOMAD test deployment. By the end of the tutorial, we will have reproduced the core upload and publishing workflows available in the NOMAD GUI. | ||
| <!-- TODO: Align the capitalization of "project"/"entry" with the docs-wide decision (#365 uses "Project"/"Entry", #374 uses "project"/"entry"), and add "project" to the glossary. --> |
There was a problem hiding this comment.
Thanks, the TODO is removed.
| !pip install python-dotenv | ||
| ``` | ||
| <!-- markdownlint-disable MD046 --> | ||
| <!-- markdownlint-enable MD046 --> |
There was a problem hiding this comment.
I do not like all of these linting adjustments throughout, the linting is there for a reason, if an adjustment is needed it should be raised and made at a more global level if possible
since this is already there partially from before, it does not need to be addressed in this PR, but please open a corresponding issue to keep track
There was a problem hiding this comment.
Right, I had them in the old page when I couldnt figure out why some tests fail. I remove them here.
| Username: siamak.nakhaie@physik.hu-berlin.de | ||
| Email: siamak.nakhaie@physik.hu-berlin.de | ||
| Authenticated as: FAIRmat Training | ||
| Username: test_siamak.nakhaie |
There was a problem hiding this comment.
I guess you could also remove your name from here, this is not validated anywhere right?
There was a problem hiding this comment.
Thanks, I agree. They are now placeholders here and in the user-search output further down.
| ```python | ||
| from nomad_utility_workflows.utils import core | ||
|
|
||
| core.NOMAD_TEST_URL = 'https://nomad-lab.eu/test/backend/api/v1' |
There was a problem hiding this comment.
Thanks! Quick context: the address itself is the test deployment's official API (its config at https://nomad-lab.eu/test/config.js sets api_base_path to /test/backend). The issue is that url='test' in nomad-utility-workflows still points to the old address, which now rejects uploads over 1 MiB, so the tutorial breaks without this line.
I saw 3 ways, and I chose 1 because I thought we want it to be published by tonight.
- Keeping the workaround so the tutorial works with the current package, open issues in nomad-utility-workflows, and update the tutorial once fixed.
- Hold this tutorial back until the package is updated.
- If possible/fine, lift the 1 MiB constraint in the old test address. I checked with the Prod deployment and it was fine. However I stayed with the workaround because I though the tutorial is meant to be performed on the Test.
@lauri-codes @JFRudzinski , I would leave the decision to you.
There was a problem hiding this comment.
Thanks for clarifying, why don't we just update nomad-utility-workflows? Can you open an issue there and list all the changes that should be made? Then I can see if we can make a quick update and release, then you could simplify this tutorial again
| `url='test'` in nomad-utility-workflows 0.3.2 points to https://nomad-lab.eu/prod/v1/test/api/v1, which currently rejects request bodies larger than 1 MiB (nginx "413 Request Entity Too Large"). | ||
| Without the workaround below, `upload_files_to_nomad` fails with a JSONDecodeError for miscellaneous_data.zip (1.97 MB) and FHI-aims.zip (1.27 MB); xps_nexus_data.zip (0.23 MB) still works. | ||
| The new test API address https://nomad-lab.eu/test/backend/api/v1 and the production API accept these files. | ||
| Once the limit on the old address is lifted, or the package sets NOMAD_TEST_URL (nomad_utility_workflows/utils/core.py) to the new address, remove the workaround below: the sentence, the snippet, and the explanation after it. --> |
There was a problem hiding this comment.
If you think a change is needed in nomad-utility-workflows, please open an issue
There was a problem hiding this comment.
FAIRmat-NFDI/nomad-utility-workflows#56 (the outdated test URL, which causes the 1 MiB upload problem).
| ``` | ||
| <!-- markdownlint-enable MD046 --> | ||
|
|
||
| The address that the package uses for `url='test'` by default currently rejects files larger than 1 MiB, so the uploads below would fail without this line. |
There was a problem hiding this comment.
If this workaround is kept: I don't think the user needs to know this, just tell them what to do directly, they don't need to know why
There was a problem hiding this comment.
Righ, I removed the explanation. The reason is now only in a comment for maintainers, linked to FAIRmat-NFDI/nomad-utility-workflows#56.
|
|
||
| # Base URL of the new NOMAD GUI on the test deployment, | ||
| # used below to build links to projects and entries | ||
| nomad_gui = 'https://nomad-lab.eu/test' |
There was a problem hiding this comment.
I would collect all configuration adjustments / variable definitions together and add it to the environmental setup section before starting
There was a problem hiding this comment.
Done, both settings are now together at the end of the environment setup.
|
|
||
| This code triggers the publication action for the DFT project and prints the server response confirming the operation. | ||
|
|
||
| <!-- TODO: Decide whether to add a section on assigning a DOI to the published project via the API (/uploads/{upload_id}/action/assign-doi), mirroring "Assign a DOI to your project" in upload_publish.md --> |
There was a problem hiding this comment.
I would say yes, but it could be deferred to a follow-up PR if you prefer, just make sure you create an issue to not lose track
There was a problem hiding this comment.
Exactly, I would defer it and for now kept a TODO for it in the page. the test deployment used in this tutorial cannot assign DOIs, so readers could not run that step yet. But if we insist to have it in the Tutorial, then we can add an admonition, with a warning, and give example to be performed on the production instance. I wouldn't say so, because users might use it for learning/testing purposes, and we dont want that. I guess majority of the users can easily use GUI and a couple of clicks to do so. Specific/advanced users would better to refer to the workflows utility docs.
| The helper `upload_files_to_nomad` both **creates a new project** and **uploads the given ZIP file** to it in a single API call. | ||
|
|
||
| !!! info "Projects and uploads" | ||
| In the NOMAD GUI, you organize your data in projects. The NOMAD API and `nomad-utility-workflows` still use the term *upload* for a project: the API endpoints retain *upload* in their paths, helper functions such as `upload_files_to_nomad` and `get_upload_by_id` work on projects, and the `upload_id` they return is the project ID. |
There was a problem hiding this comment.
something I just noticed: As far as I can see the new GUI does not use the terminology "project ID", under archive.metadata there is still upload_id, since the overarching metadata display is not yet there, it is unclear what the end results should be ... it seems to me that we should continue using upload_id though since this is the actual quantity stored, @lauri-codes ?
There was a problem hiding this comment.
Ah, ok, I see now that under Project > Settings there is a Project ID listed. Just note users can also go to archive.metadata.upload_id ... so maybe for now we want to say upload_id/project_id refer to the same quantity?
There was a problem hiding this comment.
Right. For now I updated the note to say that the upload_id identifies the project, that it can be found as Project ID under Settings > General, and that entries store it as upload_id in their metadata.
In case it helps, the new GUI currently uses both labels: "Project ID" (e.g. project settings, Actions table) and "Upload ID" (e.g. the file delete/rename dialogs). I personally think, the fine adjustments of the terminologies used in the tutorial can be addressed later.
a13de03 to
227b171
Compare
…uts, update TODOs, remove lint comments
c2e829d to
794a292
Compare
Updates the "Upload and share with the API" tutorial for GUI v2 projects. for #376.
Important TODO and the reason: