-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serve sumission schema files from backend #1172
Conversation
…ema; mount files to /static path.
…y schema files from backend's /static path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a pretty elegant solution. I had one comment on the code, and I have additional questions about deployment - is there anything that needs to be done on the spin side to make sure there's no problem creating the static file directory?
Not that I'm aware of, but we should find out as soon as this goes to dev if there is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I tested this locally by visiting some of the /static
urls and confirming that I got some neat json files as a response, and checking that the DH works correctly (i.e. expected columns, validation). As far as I could tell, things appear to be in working order.
Fixes #1166
Summary
This is partially to support the Field Notes app, but I think it also has benefits for the main submission portal as well. The gist is to allow API clients (whether that's the submission portal or the app) to get submission schema artifacts from the API instead of bundling them in the client application. For the submission portal this hasn't been a major problem (other than the weirdness of having a PyPI artifact as a frontend dependency) since the frontend and backend are part of the same codebase and released at the same time. That won't necessarily be true for the Field Notes app so we want to be able to dynamically fetch the schema.
Details
nmdc_server/static_files.py
defines a path to hold static files and a function which knows how to introspect files provided by thenmdc_submission_schema
package and write JSON files into the static file directory. In particular it produces a JSON file representing the whole submission schema (used by the submission portal), files representing individual classes of the schema (likely to be used by the Field Notes app), and the GOLD ecosystem tree (used by the submission portal and likely to be used by the Field Notes app)./static
path./static
routes instead of importing packaged files.nmdc-submission-schema
as a backend dependency, remove it as a frontend dependency.nmdc-schema
dependencies to the latest version.Comments
I decided on the static file approach because FastAPI will serve the right headers (I think mayble Etag) in the responses to allow browsers to aggressively cache the responses.
In the future we could consider whether we can piggyback on this approach to also remove the
nmdc-server
frontend dependency.