-
Notifications
You must be signed in to change notification settings - Fork 1
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
jsonld templating playground #28
Conversation
✅ Deploy Preview for docs-geoconnex-us ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This is a really good idea. I would extend it, rather than starting with some raw GeoJSON output, have more of a builder, similar to https://technicalseo.com/tools/schema-markup-generator/ |
Sounds good, thanks for that link! I agree there is value in a structured playground with dropdown options to guide, although I also think there is value in keeping an unstructured playground as another separate page (since a user may want to experiment generally / copy paste an arbitrary template/response). The base functionality for the unstructured playground is close to done, just need the backend service live. Need to get a better idea of how we will be deploying back-end infra generally as we refactor scheduler (i.e. docker swarm vs k8s vs separate individual service etc). I can deploy it more simply if we don't want to be blocked on that. |
If it can be containerized and accessed via http get/post then google cloud run is fine as an interim. But you should discuss with @adplincinst |
Ben is going to walk me through the Google cloud credentials this upcoming week and I will set up cloud run; in the meantime, I experimented with adding sparnatural to this. Alternative, there is a langchain LLM loader for rdf graphs which I looked at as well: https://python.langchain.com/docs/integrations/graphs/rdflib_sparql/ |
Spanatural or similar would be good if we can load it with the relevant types for us. Which we haven't actually specified they well. Probably some schema.org types for administrative boundaries and cuahsi site types. |
@ksonda This should be good if you want to take a look at it. Made the UI a bit nicer and now have the Google cloud infra up and running for it. @webb-ben let me know if you think I should change anything in the |
|
This comment was marked as resolved.
This comment was marked as resolved.
Once we also have settled on the code for the function in GCP can we archive that somewhere in this repository? |
The template playground doesnt' seem to work for some reason. Maybe we need to pick a simpler example, like from one of the state gage endpoints where wha'ts coming through is just one table as geojson |
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.
@ksonda if it wasn't working that is probably since I was working on making some changes after Ben and I aligned this morning. Should be working now.
Ben, please feel free to suggest / edit directly anything if I am still misunderstanding.
@functions_framework.http | ||
def templating(request: flask.Request): | ||
"""HTTP Cloud Function. | ||
Args: |
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.
@webb-ben here is the backend code
const templatingRequest = { | ||
source_values: { | ||
// we create a top level data key to mimic the fact pygeoapi does it | ||
data: dataToSend, | ||
}, | ||
template: template, | ||
}; |
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.
instead of doing this on the backend, i think it is easiest to just wrap the jsonld with a data key to mimic what pygeoapi is doing. Works for me. But wanted to confirm that this is reasonable
Notes on templating within pygeoapi | ||
</div> | ||
|
||
When pygeoapi applies a Jinja template, it considers the entire source JSON-LD to be the top-level key named `data`. Otherwise, the Jinja templating in pygeoapi is standard and follows expected patterns. |
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.
Correct?
In the page I added, users have 3 code editors. These are live editors with syntax highlighting and we can add schema validation if we want in the future as well. When they press the button, it applies the template to the raw json by calling a simple python backend service which applies the jinja template
Please don't merge since this requires a live python backend that is trivial and I have implemented locally, but this is not yet deployed to google cloud