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

Only add files with modification outside doc blocks #23327

Merged
merged 3 commits into from
May 12, 2023

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented May 12, 2023

What does this PR do?

Add files for doctesting only when they have modifications outside docstrings.

(offline message from Sylvain)

One small improvement I see is for the docstrings: for now the tests are launched on a file if we modify it, but I would only launch it if docstrings are modified (e.g. check the modifications are correct) to go faster. If changes in the code of a model file (for instance) trigger a doctest failure we will see it after.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 12, 2023

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

@ydshieh ydshieh marked this pull request as ready for review May 12, 2023 11:29
@@ -151,7 +151,7 @@
"psutil",
"pyyaml>=5.1",
"pydantic",
"pytest",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

min. version to make the following work (used in src/transformers/testing_utils.py for the doctest in PRs)

from _pytest.doctest import Module,

Comment on lines +230 to +244
# Now for modified files
elif (
diff_obj.change_type in ["M", "R"]
and diff_obj.b_path.endswith(".py")
or diff_obj.b_path.endswith(".mdx")
):
# In case of renames, we'll look at the tests using both the old and new name.
if diff_obj.a_path != diff_obj.b_path:
code_diff.extend([diff_obj.a_path, diff_obj.b_path])
else:
# Otherwise, we check modifications are in code and not docstrings.
if diff_is_docstring_only(repo, commit, diff_obj.b_path):
print(f"Ignoring diff in {diff_obj.b_path} as it only concerns docstrings or comments.")
else:
code_diff.append(diff_obj.a_path)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copied from

def get_diff(repo, base_commit, commits):
with a bit modification.

@ydshieh ydshieh requested a review from amyeroberts May 12, 2023 11:34
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for adding!

@ydshieh ydshieh force-pushed the only_modified_doc_block branch from c2589a8 to 0dd48c7 Compare May 12, 2023 13:43
@ydshieh ydshieh merged commit a3975f9 into main May 12, 2023
@ydshieh ydshieh deleted the only_modified_doc_block branch May 12, 2023 14:35
sheonhan pushed a commit to sheonhan/transformers that referenced this pull request May 15, 2023
* min. version for pytest

* fix

* fix

---------

Co-authored-by: ydshieh <[email protected]>
ydshieh added a commit that referenced this pull request May 15, 2023
gojiteji pushed a commit to gojiteji/transformers that referenced this pull request Jun 5, 2023
* min. version for pytest

* fix

* fix

---------

Co-authored-by: ydshieh <[email protected]>
novice03 pushed a commit to novice03/transformers that referenced this pull request Jun 23, 2023
* min. version for pytest

* fix

* fix

---------

Co-authored-by: ydshieh <[email protected]>
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.

3 participants