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

Refac docstrings in training_utils.py #9724

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RogerSinghChugh
Copy link

What does this PR do?

Fixes #9567

Before submitting

Who can review?

@a-r-r-o-w @stevhliu

Copy link
Member

@stevhliu stevhliu 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! Can you run make style to automatically apply the correct style corrections to fix the failing CI test?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@RogerSinghChugh
Copy link
Author

LGTM, thanks! Can you run make style to automatically apply the correct style corrections to fix the failing CI test?

Hi @stevhliu, did like you asked. Will make sure to run the command beforehand in the future.

@stevhliu
Copy link
Member

Hmm, can you also please try running make quality?

@RogerSinghChugh
Copy link
Author

Hmm, can you also please try running make quality?

Hi @stevhliu I tried running make quality and saw that it found 19 errors, none of them were in the files I changed though, should I be making those changes and then pushing the code?

Just for reference here is one of the errors I got from after running the make command.

tests\models\test_modeling_common.py:479:20: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
477 |             return
478 |
479 |         assert all(type(proc) == AttnProcessor2_0 for proc in model.attn_processors.values())
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
480 |         with torch.no_grad():
481 |             if self.forward_requires_fresh_args:

@a-r-r-o-w
Copy link
Member

Could you upgrade/downgrade your ruff version to 0.1.5 and try again?

@RogerSinghChugh
Copy link
Author

RogerSinghChugh commented Oct 23, 2024

Could you upgrade/downgrade your ruff version to 0.1.5 and try again?

Hi @a-r-r-o-w , after downgrading ruff to the version you specified, I get the following error messages:

ruff check examples scripts src tests utils benchmarks setup.py --fix
ruff format examples scripts src tests utils benchmarks setup.py
1114 files left unchanged
doc-builder style src/diffusers docs/source --max_len 119
process_begin: CreateProcess(NULL, doc-builder style src/diffusers docs/source --max_len 119, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:59: style] Error 2

Trying to fix that, do you have any insights about this issue? Also apologies in advance if this is not the place to discuss issues like this.

@RogerSinghChugh
Copy link
Author

Could you upgrade/downgrade your ruff version to 0.1.5 and try again?

Hi @a-r-r-o-w , after downgrading ruff to the version you specified, I get the following error messages:

ruff check examples scripts src tests utils benchmarks setup.py --fix
ruff format examples scripts src tests utils benchmarks setup.py
1114 files left unchanged
doc-builder style src/diffusers docs/source --max_len 119
process_begin: CreateProcess(NULL, doc-builder style src/diffusers docs/source --max_len 119, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:59: style] Error 2

Trying to fix that, do you have any insights about this issue? Also apologies in advance if this is not the place to discuss issues like this.

Hi @a-r-r-o-w @stevhliu
I fixed the issues I was encountering.

I ran the two make commands.

Output from make quality:

ruff check examples scripts src tests utils benchmarks setup.py
src\diffusers\loaders\lora_pipeline.py:345:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:609:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:877:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:1242:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:1321:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:1448:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:1847:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:1918:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:2050:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:2417:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:2702:1: W293 [*] Blank line contains whitespace
src\diffusers\loaders\lora_pipeline.py:2756:1: W293 [*] Blank line contains whitespace
Found 12 errors.
[*] 12 fixable with the `--fix` option.
make: *** [Makefile:43: quality] Error 1

Output (partial, actual output is too big) from make style:

PS <pathToDiffusers>\diffusers> make style
ruff check examples scripts src tests utils benchmarks setup.py --fix
Found 12 errors (12 fixed, 0 remaining).
ruff format examples scripts src tests utils benchmarks setup.py
360 files reformatted, 754 files left unchanged
doc-builder style src/diffusers docs/source --max_len 119
Overwriting content of src/diffusers\callbacks.py.
Overwriting content of src/diffusers\commands\fp16_safetensors.py.
.
.
.
Overwriting content of src/diffusers\video_processor.py.
Cleaned 360 files!
<intialPath>/chocolatey/lib/make/tools/install/bin/make.exe autogenerate_code
make[1]: Entering directory '<pathToDiffusers>/diffusers'
running deps_table_update
updating src/diffusers/dependency_versions_table.py
make[1]: Leaving directory '<pathToDiffusers>/diffusers'
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe extra_style_checks
make[1]: Entering directory '<pathToDiffusers>/diffusers'
py utils/custom_init_isort.py
py utils/check_doc_toc.py --fix_and_overwrite
make[1]: Leaving directory '<pathToDiffusers>/diffusers'

What should my next steps be, do I have to run the make style with the --fix like mentioned in the output of that command? Also is there any documentation (which I might have missed) which contains details on how to proceed after running the make commands. I saw some documentation in CONTRIBUTING.md, is there any more?

Also just want to mention I really appreciate all the help I'm getting, thank you.

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.

[community] Improving docstrings and type hints
4 participants