Skip to content

Commit

Permalink
fix: update to solve the error of integration tests in CI (#4314)
Browse files Browse the repository at this point in the history
<!-- Thanks for your contribution! As part of our Community Growers
initiative 🌱, we're donating Justdiggit bunds in your name to reforest
sub-Saharan Africa. To claim your Community Growers certificate, please
contact David Berenstein in our Slack community or fill in this form
https://tally.so/r/n9XrxK once your PR has been merged. -->

# Description

New update to try solving the error persistent in the integration tests
on github actions.
The test has been split to see if that doesn't trigger the error, and
the timeout has been set at the job level instead of a step.

Related to #4307

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)

**How Has This Been Tested**

(Please describe the tests that you ran to verify your changes. And
ideally, reference `tests`)

- [ ] Test A
- [ ] Test B

**Checklist**

- [ ] I followed the style guidelines of this project
- [ ] I did a self-review of my code
- [ ] My changes generate no new warnings
- [ ] 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)
- [ ] I have added relevant notes to the `CHANGELOG.md` file (See
https://keepachangelog.com/)

---------

Co-authored-by: Agustin Piqueres <[email protected]>
  • Loading branch information
plaguss and Agustin Piqueres authored Nov 26, 2023
1 parent 2522d24 commit 658823a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
name: Argilla python tests
runs-on: ${{ inputs.runsOn }}
continue-on-error: true
timeout-minutes: 30
services:
search_engine:
image: ${{ inputs.searchEngineDockerImage }}
Expand Down Expand Up @@ -94,7 +95,6 @@ jobs:
run: |
pip install -e ".[server,listeners]"
pytest --cov=argilla --cov-report=xml:${{ env.COVERAGE_REPORT }}.xml ${{ inputs.pytestArgs }} -vs
timeout-minutes: 30
- name: Upload coverage report artifact
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions src/argilla/training/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
if TYPE_CHECKING:
import spacy

from argilla.client.feedback.integrations.huggingface import FrameworkCardData


class ArgillaTrainer(object):
_logger = logging.getLogger("ArgillaTrainer")
Expand Down Expand Up @@ -407,13 +409,11 @@ def save(self, output_dir: str):
Saves the model to the specified path.
"""

@abstractmethod
def get_model_card_data(self, card_data_kwargs: Dict[str, Any]) -> "FrameworkCardData":
"""
Generates a `FrameworkCardData` instance to generate a model card from.
"""

@abstractmethod
def push_to_huggingface(self, repo_id: str, **kwargs) -> Optional[str]:
"""
Uploads the model to [Huggingface Hub](https://huggingface.co/docs/hub/models-the-hub).
Expand Down
62 changes: 34 additions & 28 deletions tests/integration/client/feedback/training/test_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,60 +237,66 @@ def correct_formatting_func_with_yield(sample):
train_with_cleanup(trainer, __OUTPUT_DIR__)


def formatting_func_std(sample):
responses = []
question = sample["label"]
context = sample["text"]
for answer in sample["question-1"]:
if not all([question, context, answer["value"]]):
continue
responses.append((question, context, answer["value"]))
return responses


def formatting_func_with_yield(sample):
question = sample["label"]
context = sample["text"]
for answer in sample["question-1"]:
if not all([question, context, answer["value"]]):
continue
yield question, context, answer["value"]


@pytest.mark.skip(
reason="For some reason this test fails in CI, but not locally. It just says: Error: The operation was canceled."
)
@pytest.mark.parametrize(
"formatting_func",
(formatting_func_std, formatting_func_with_yield),
)
@pytest.mark.usefixtures(
"feedback_dataset_guidelines",
"feedback_dataset_fields",
"feedback_dataset_questions",
"feedback_dataset_records",
)
def test_question_answering_with_formatting_func(
feedback_dataset_fields, feedback_dataset_questions, feedback_dataset_records, feedback_dataset_guidelines
feedback_dataset_fields,
feedback_dataset_questions,
feedback_dataset_records,
feedback_dataset_guidelines,
formatting_func,
):
dataset = FeedbackDataset(
guidelines=feedback_dataset_guidelines,
fields=feedback_dataset_fields,
questions=feedback_dataset_questions,
)
dataset.add_records(records=feedback_dataset_records * 5)
dataset.add_records(records=feedback_dataset_records * 2)
with pytest.raises(
ValueError,
match=re.escape(
f"formatting_func must return {QuestionAnsweringReturnTypes.__annotations__['format']}, not <class 'list'>"
),
):
task = TrainingTask.for_question_answering(lambda x: {})
trainer = ArgillaTrainer(dataset=dataset, task=task, framework="transformers")
trainer.update_config(num_iterations=1)
train_with_cleanup(trainer, __OUTPUT_DIR__)

def formatting_func(sample):
responses = []
question = sample["label"]
context = sample["text"]
for answer in sample["question-1"]:
if not all([question, context, answer["value"]]):
continue
responses.append((question, context, answer["value"]))
return responses
ArgillaTrainer(dataset=dataset, task=task, framework="transformers")

task = TrainingTask.for_question_answering(formatting_func)
trainer = ArgillaTrainer(dataset=dataset, task=task, framework="transformers")
trainer.update_config(num_iterations=1)
train_with_cleanup(trainer, __OUTPUT_DIR__)

def formatting_func_with_yield(sample):
question = sample["label"]
context = sample["text"]
for answer in sample["question-1"]:
if not all([question, context, answer["value"]]):
continue
yield question, context, answer["value"]

task = TrainingTask.for_question_answering(formatting_func_with_yield)
trainer = ArgillaTrainer(dataset=dataset, task=task, framework="transformers")
trainer.update_config(num_iterations=1)
train_with_cleanup(trainer, __OUTPUT_DIR__)


@pytest.mark.usefixtures(
"feedback_dataset_guidelines",
Expand Down

0 comments on commit 658823a

Please sign in to comment.