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

ref: Move get services out of API methods #4216

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Oct 20, 2024

It doesn't have added value to put get_xxx_service methods in Depends injections. It even makes the code harder to read.
So this PR moves them to the code.
This PR also removes some response_model when they can be set as the method return type.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 20, 2024
@@ -19,11 +19,11 @@ def post_validate_code(code: Code):
)
except Exception as e: # noqa: BLE001
logger.opt(exception=True).debug("Error validating code")
return HTTPException(status_code=500, detail=str(e))
raise HTTPException(status_code=500, detail=str(e))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was incorrect ?

@cbornet cbornet force-pushed the api-services branch 2 times, most recently from d54aefe to d3c38e9 Compare October 20, 2024 21:12
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@italojohnny FYI

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 21, 2024
@cbornet cbornet enabled auto-merge (squash) October 22, 2024 11:23
@cbornet cbornet merged commit c85cd91 into langflow-ai:main Oct 22, 2024
28 checks passed
@cbornet cbornet deleted the api-services branch October 22, 2024 11:27
@cbornet
Copy link
Collaborator Author

cbornet commented Oct 22, 2024

I had to rollback some changes on files.py as I couldn't mock get_storage_service() globally and had to only mock it for fastapi.
I believe it's not sane to have constraints on code imposed by the way we test...
Also endpoints tested by the tests that use a mock (test_upload_file, test_download_file, ...) are also tested by a non-mocked test : test_file_operations. So maybe we could just remove those mocked tests ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants