-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: import errors when importing from
argilla.feedback
(#3471)
# Description This PRs fixes the `ModuleNotFoundError` and `ImportError` that occurred when trying to import something from `argilla.feedback` module. The first error was caused because in #3336 the telemetry was included in the `ArgillaTrainer`, but in the `argilla.utils.telemetry` module some optional dependencies used by the server were being imported. The second one was caused because the module in which `HuggingFaceDatasetMixin` (and from which `FeedbackDataset` is inheriting) class lives was importing classes from the `argilla.client.feedback.config` module, which was importing `pyyaml` in its root causing the `ImportError`. Closes #3468 **Type of change** - [x] Bug fix (non-breaking change which fixes an issue) **How Has This Been Tested** I've created a wheel of this branch, installed in a new virtual environment and I was able to import something `argilla.feedback` module without errors. **Checklist** - [ ] I added relevant documentation - [x] follows the style guidelines of this project - [x] I did a self-review of my code - [ ] I made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [x] I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: Francisco Aranda <francis@argilla.io>
- Loading branch information
1 parent
2d0029a
commit d37ea7e
Showing
7 changed files
with
129 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2021-present, the Recognai S.L. team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright 2021-present, the Recognai S.L. team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pytest | ||
from argilla.server.errors.api_errors import APIErrorHandler | ||
from argilla.server.errors.base_errors import ( | ||
EntityAlreadyExistsError, | ||
EntityNotFoundError, | ||
GenericServerError, | ||
ServerError, | ||
) | ||
from argilla.server.schemas.datasets import Dataset | ||
from fastapi import Request | ||
|
||
mock_request = Request(scope={"type": "http", "headers": {}}) | ||
|
||
|
||
@pytest.mark.asyncio | ||
class TestAPIErrorHandler: | ||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize( | ||
["error", "expected_event"], | ||
[ | ||
( | ||
EntityNotFoundError(name="mock-name", type="MockType"), | ||
{ | ||
"accept-language": None, | ||
"code": "argilla.api.errors::EntityNotFoundError", | ||
"type": "MockType", | ||
"user-agent": None, | ||
}, | ||
), | ||
( | ||
EntityAlreadyExistsError(name="mock-name", type=Dataset, workspace="mock-workspace"), | ||
{ | ||
"accept-language": None, | ||
"code": "argilla.api.errors::EntityAlreadyExistsError", | ||
"type": "Dataset", | ||
"user-agent": None, | ||
}, | ||
), | ||
( | ||
GenericServerError(RuntimeError("This is a mock error")), | ||
{ | ||
"accept-language": None, | ||
"code": "argilla.api.errors::GenericServerError", | ||
"type": "builtins.RuntimeError", | ||
"user-agent": None, | ||
}, | ||
), | ||
( | ||
ServerError(), | ||
{ | ||
"accept-language": None, | ||
"code": "argilla.api.errors::ServerError", | ||
"user-agent": None, | ||
}, | ||
), | ||
], | ||
) | ||
async def test_track_error(self, test_telemetry, error, expected_event): | ||
await APIErrorHandler.track_error(error, request=mock_request) | ||
|
||
test_telemetry.assert_called_once_with("ServerErrorFound", expected_event) |