Skip to content
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

[Question]: Can you use PyMapMe for translating one model's fields names to another? #1

Open
wakatara opened this issue Jul 29, 2023 · 0 comments

Comments

@wakatara
Copy link

Perhaps not your original use case here, but I've built a FastAPI interface with pydantic and SQLAlchemy for a complex astronomy project.

One of the APIs I pull from is a lisp based interface that returns many short forms and ALL CAPS field names and such, many of which need to be "translated" into the actual model I'm goign to be using (which is more lower case, fully named, and snake cased. For returns from the model, I am trying to avoid a whack long set of statements like this in numerous places and for some API responses tht return a lot of fields.

    data = resp["result"]["PARAMETERS"]
     
    # Now we have the datalake file path and some calibrate fields we can insert image.
    fits_headers['pixel_scale'] = data["QUALITIES-INFO"]["PIXEL-SCALE"]
    fits_headers['gain'] = data["QUALITIES-INFO"]["GAIN"]

I notice it looks like PyMapMe's use case is more about re-purposing models than mapping fields, but was wondeirng if it could serve the same purpose. In the above, instance I have both a Images model and a Calibration model which reflect my underlying database tables, just nothing that represents the stuff coming back from the lisp API I call.

lemme know! Interesting project now I'm messing more with Python than Go and ruby...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant