Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Maybe replace client.py with fastapi_client package? #29

Closed
rabernat opened this issue Jan 18, 2022 · 1 comment
Closed

Maybe replace client.py with fastapi_client package? #29

rabernat opened this issue Jan 18, 2022 · 1 comment

Comments

@rabernat
Copy link
Contributor

We should consider replacing the current client.py with the fastapi_client package: https://github.com/dmontagu/fastapi_client

Generate a mypy- and IDE-friendly API client from an OpenAPI spec.

  • Sync and async interfaces are both available
  • Comes with support for the OAuth2.0 password flow
  • Easily extended, with built-in support for request middleware
  • Designed for integration with FastAPI, but should work with most OpenAPI specs
  • Makes use of https://github.com/OpenAPITools/openapi-generator

...

Generated clients will have the following dependencies:

  • pydantic for models
  • httpx for networking
  • fastapi for jsonable_encoder and OAuth models (I hope to eventually remove this as a dependency)
  • typing_extensions for Enums via Literal (I eventually hope to replace this with standard enums)

This package will automatically generate a python client API based on the openapi spec (same interface used in #28). This would mean that we wouldn't have to actually import pangeo_forge_orchestrator from the client; they would communicate solely through a single json file.

This would enable us to eventually factor apart the client (including cli) and server into separate packages, which is probably the right architecture in the long run.

@cisaacstern
Copy link
Member

Per our conversation this morning, the need for client instances in https://github.com/pangeo-forge/registrar further endorses this proposal, particularly

This would enable us to eventually factor apart the client (including cli) and server into separate packages, which is probably the right architecture in the long run.

which will allow us to make the client a separate pip-installable package.

One layer we may want to add on top of fastapi_client is the option to parse api responses into their corresponding SQLModel models. Having the dot-attributed objects is much more developer-friendly as compared with dicts.

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

No branches or pull requests

2 participants