Skip to content

Restore original task in test_warning_logs#17985

Merged
ydshieh merged 2 commits intohuggingface:mainfrom
ydshieh:fix_pipeline_test_2
Jul 1, 2022
Merged

Restore original task in test_warning_logs#17985
ydshieh merged 2 commits intohuggingface:mainfrom
ydshieh:fix_pipeline_test_2

Conversation

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Jul 1, 2022

What does this PR do?

test_warning_logs modifies PIPELINE_REGISTRY via PIPELINE_REGISTRY.register_pipeline(alias, {}), which fails the tests in TextClassificationPipelineTests.

This PR restores the original task at the end of test_warning_logs.

cc @aarnphm

@ydshieh ydshieh requested review from Narsil and sgugger July 1, 2022 17:04
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jul 1, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

nice catch. cc @sgugger @LysandreJik

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

Comment on lines 788 to 789
# restore
PIPELINE_REGISTRY.register_pipeline(alias, original_task)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be done in a finally after a try for the rest, so it doesn't mess other tests when it fails.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is the last statement in test_warning_logs. By the rest, what do you mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I guess I understand. Let me try

Copy link
Contributor

Choose a reason for hiding this comment

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

so it would be

try:
    with ...
finally:
    PIPELINE_REGISTRY.register_pipeline(alias, original_task)

self.assertIn(f"{alias} is already registered", cm.out)
finally:
# restore
PIPELINE_REGISTRY.register_pipeline(alias, original_task)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this good 😄 ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup!

@ydshieh ydshieh merged commit 6f0723a into huggingface:main Jul 1, 2022
@ydshieh ydshieh deleted the fix_pipeline_test_2 branch July 1, 2022 18:44
viclzhu pushed a commit to viclzhu/transformers that referenced this pull request Jul 18, 2022
Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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.

4 participants