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

Sylvanie85/issue61 #82

Merged
merged 5 commits into from
May 16, 2024
Merged

Sylvanie85/issue61 #82

merged 5 commits into from
May 16, 2024

Conversation

sylvanie85
Copy link
Contributor

I did some refactoring as my first issue on nachet-backend.
The issue #61 was deprecated because the code has changed a lot since it was created. But I did make some fixes to the exception handling.

Copy link
Collaborator

@ChromaticPanic ChromaticPanic left a comment

Choose a reason for hiding this comment

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

Can we move the Error class definitions into a separate module so that we are not redefining them in multiple files?

There is a custom_exceptions.py file

@Francois-Werbrouck
Copy link
Contributor

Can we move the Error class definitions into a separate module so that we are not redefining them in multiple files?

There is a custom_exceptions.py file

The issue this PR is based upon #61 which basically has the goal to remove the custom_exceptions file and redistribute the error to be module based instead

@ChromaticPanic
Copy link
Collaborator

ChromaticPanic commented May 15, 2024

Can we move the Error class definitions into a separate module so that we are not redefining them in multiple files?
There is a custom_exceptions.py file

The issue this PR is based upon #61 which basically has the goal to remove the custom_exceptions file and redistribute the error to be module based instead

That's okay for exceptions unique to a module, but some exceptions are shared. For example we do not redefine KeyError because that is something that is common.

For example the proposed approach has ApiErrors defined in multiple files. That seems wrong on so many levels.

@ChromaticPanic
Copy link
Collaborator

Can we move the Error class definitions into a separate module so that we are not redefining them in multiple files?
There is a custom_exceptions.py file

The issue this PR is based upon #61 which basically has the goal to remove the custom_exceptions file and redistribute the error to be module based instead

I can elaborate on the issue as follows

Module 1 defines ApiError
Module 2 defines ApiError
Module 3 imports Module 1 and 2 and wants to handle the exceptions = name collision
There are also now 2 potential definitions of what ApiError means, when the reality is that they probably both refer to an issue with connecting an azure end point

Now if ApiError in Module 1 and 2 are in fact different but kinda related then they should inherit from a common parent ApiError but then they should have their own name

@Francois-Werbrouck
Copy link
Contributor

Can we move the Error class definitions into a separate module so that we are not redefining them in multiple files?
There is a custom_exceptions.py file

The issue this PR is based upon #61 which basically has the goal to remove the custom_exceptions file and redistribute the error to be module based instead

That's okay for exceptions unique to a module, but some exceptions are shared. For example we do not redefine KeyError because that is something that is common.

For example the proposed approach has ApiErrors defined in multiple files. That seems wrong on so many levels.

Reviewing the changes I agree. The custom_exception file had too many exceptions in it, which are now module based. However defining APIErrors in 6+ files seems wrong.

Copy link
Contributor

@Francois-Werbrouck Francois-Werbrouck left a comment

Choose a reason for hiding this comment

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

Based on the discussion with @ChromaticPanic we should have a module to inherit the reccuring error Ex: class ProcessInferenceResultsError(APIErrors) :

@sylvanie85
Copy link
Contributor Author

Based on the discussion with @ChromaticPanic we should have a module to inherit the reccuring error Ex: class ProcessInferenceResultsError(APIErrors) :

So i need to create a new file to inherit the exception as was custom_exeptions ?

@ChromaticPanic
Copy link
Collaborator

ChromaticPanic commented May 15, 2024

Based on the discussion with @ChromaticPanic we should have a module to inherit the reccuring error Ex: class ProcessInferenceResultsError(APIErrors) :

So i need to create a new file to inherit the exception as was custom_exeptions ?

Yeah I would make that common ApiError

But also in each file I would use unique names for example in swin.py instead of ProcessInferenceResultsError(ApiError) I would name it SwinError(ApiError) or SwinApiError (I don't know at this point how many error types will be thrown by each module)
Then it would work with the idea of having unique module errors defined in #61

Copy link
Contributor

@Francois-Werbrouck Francois-Werbrouck left a comment

Choose a reason for hiding this comment

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

I like the new exception file and custom naming per module. I willl look into adapting the datastore to this standard!

LGTM! 👍🏻

@sylvanie85 sylvanie85 merged commit 4d641f9 into main May 16, 2024
8 checks passed
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

Successfully merging this pull request may close these issues.

Refactor function from module in the backend to catch errors and raise custom exceptions
3 participants