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

AIP-81 Implement Missing Bulk Insert API Endpoints will be used from CLI Commands #42560

Open
1 task done
bugraoz93 opened this issue Sep 28, 2024 · 11 comments
Open
1 task done
Assignees
Labels
AIP-81 Enhanced Security in CLI via Integration of API area:API Airflow's REST/HTTP API area:CLI kind:feature Feature Requests

Comments

@bugraoz93
Copy link
Collaborator

bugraoz93 commented Sep 28, 2024

Description

AIP-81

To enhance the API functionality, this umbrella ticket organizes the development of missing endpoints in FastAPI for key features like connections, variables, and more. Implementing these endpoints will enable users to manage resources more effectively through the API, improving usability and reducing the need for multiple workarounds.
The workload aims to help secure CLI by using these endpoints.

Missing Endpoints

Code of Conduct

@bugraoz93 bugraoz93 added kind:feature Feature Requests needs-triage label for new issues that we didn't triage yet labels Sep 28, 2024
@dosubot dosubot bot added area:API Airflow's REST/HTTP API area:CLI labels Sep 28, 2024
@Lee-W Lee-W added AIP-81 Enhanced Security in CLI via Integration of API and removed needs-triage label for new issues that we didn't triage yet labels Sep 30, 2024
@bugraoz93 bugraoz93 changed the title AIP-81 Implement Missing API Endpoints will be used from CLI Commands AIP-81 Implement Missing Import/Export API Endpoints will be used from CLI Commands Nov 4, 2024
@bugraoz93 bugraoz93 self-assigned this Nov 6, 2024
@bugraoz93
Copy link
Collaborator Author

Hey @pierrejeambrun, I need your help on AIP-81 if you have time. It is related to new set endpoints in FastAPI.

&TLDR
This is part of AIP-81. The aim is to use these endpoints from CLI. There are missing ones and one set of missing ones are these. I would like to get your help on reviews and your take on this before implementing because impacting more than one model and multiple endpoint in FastAPI.

I created these issues as file but I am not sure if we should accept files as an input in the API since they are harder to validate if the file is safe in APIs and brought more security concerns. I am thinking we can create POST endpoints that accept the models in bulks like post_connections endpoint and parse the files in CLI before sending and receiving request/response from API. What do you think?

Many thanks!

@jason810496
Copy link
Contributor

Hi @bugraoz93, if I may suggest, I would +1 for the second option (parsing the files at the CLI level).
This approach would allow Pydantic data models to serve as the interface within the codebase for both the CLI and API, decoupling CLI-specific file-parsing logic from the API. Additionally, this would enable the CLI to directly utilize the public APIs.

By the way, I'm available to take on other missing APIs for AIP-81 if needed.

@bugraoz93
Copy link
Collaborator Author

Hi @bugraoz93, if I may suggest, I would +1 for the second option (parsing the files at the CLI level).
This approach would allow Pydantic data models to serve as the interface within the codebase for both the CLI and API, decoupling CLI-specific file-parsing logic from the API. Additionally, this would enable the CLI to directly utilize the public APIs.

Hi @jason810496, great to hear your +1 on this! I believe this will make both the CLI and API endpoints more secure and happy 😄

By the way, I'm available to take on other missing APIs for AIP-81 if needed.

Amazing! Once the approach is aligned, I’ll break these down further. Any help would be much appreciated!

@bugraoz93
Copy link
Collaborator Author

I've removed the export functionality, as we can retrieve all necessary data via the list endpoints and parse them to a given file from the CLI. This approach will reduce the workload and improve security for the API and the CLI. The more I looked at these endpoints and the approach, the more I felt this wasn’t even up for discussion, as this is clearly the better approach.

Additionally, I've created the remaining issues for anyone who wants to pick them up. I haven’t labelled them as good first issue yet.
cc: @jason810496 @josix if you're interested in more issues :)

@jason810496
Copy link
Contributor

Sounds reasonable. I can take on both issues. Could you please assign them to me? Thanks !
By the way, I noticed a possible typo for the Pools endpoint. Should it be Insert Multiple Variables?

@bugraoz93
Copy link
Collaborator Author

Sounds reasonable. I can take on both issues. Could you please assign them to me? Thanks !
By the way, I noticed a possible typo for the Pools endpoint. Should it be Insert Multiple Variables?

Nice one! Fixed. Assigning both. Thanks for your effort! :)

@bugraoz93
Copy link
Collaborator Author

Can you comment them @jason810496? This is the only way I can see you in the issue.

@pierrejeambrun
Copy link
Member

pierrejeambrun commented Nov 12, 2024

Most of these resources Connection Pool Variable already have a POST endpoint to create 1.

The CLI can either re-use with a loop and async calls to create multiple of them quickly as needed. (which can be enough at this point). Or we can develop a bulk insert endpoint, not sure if this is needed.

@bugraoz93
Copy link
Collaborator Author

Most of these resources Connection Pool Variable already have a POST endpoint to create 1.

The CLI can either re-use with a loop and async calls to create multiple of them quickly as needed. (which can be enough at this point). Or we can develop a bulk insert endpoint, not sure if this is needed.

In that sense, those endpoints are indeed not necessary. I agree that even hundreds of calls per second shouldn’t be an issue for FastAPI. However, for better exception handling and an improved user experience, I’d prefer to handle all inserts in a single request. Otherwise, if the request fails for multiple entries, users would need to split the file, identify each issue, and then retry each entry individually or through the UI/CLI as a single resource.

Let’s proceed with implementing the bulk insert endpoints, as it seems you’re not strictly opposed.

@bugraoz93 bugraoz93 changed the title AIP-81 Implement Missing Import/Export API Endpoints will be used from CLI Commands AIP-81 Implement Missing Bulk Insert API Endpoints will be used from CLI Commands Nov 12, 2024
@pierrejeambrun
Copy link
Member

pierrejeambrun commented Nov 12, 2024

Yes of course if we need a bulk insert for that use case we can definitely implement it.

How do we plan on handling failures ? (Even for bulk insert). Do we fail the entire transaction, or do we create those that could be created and return back the whole bunch of errors for the failing ones ?

@bugraoz93
Copy link
Collaborator Author

Awesome, thanks!

These endpoints will primarily be used when users are importing models from a file via the CLI.

My thinking is to fail the entire transaction and return a list of errors for any entries that caused issues. This way, users can quickly locate and fix specific items in the file or request, and then resend it. Creating only a portion of the entries would still be inconvenient for both API and CLI users. Not only is editing but also removing partial entries difficult if they’re spread across different sections of the list.

From the CLI perspective, we can return the response message to the user as we do with the API if it fails, so both are aligned.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-81 Enhanced Security in CLI via Integration of API area:API Airflow's REST/HTTP API area:CLI kind:feature Feature Requests
Development

No branches or pull requests

4 participants