KEMBAR78
Fix default values of getenv by cyyever · Pull Request #39867 · huggingface/transformers · GitHub
Skip to content

Conversation

@cyyever
Copy link
Contributor

@cyyever cyyever commented Aug 2, 2025

What does this PR do?

The default value of getenv should be a string or None.

Signed-off-by: cyy <cyyever@outlook.com>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

[For maintainers] Suggested jobs to run (before merge)

run-slow: modernbert, whisper

@Rocketknight1
Copy link
Member

Not sure about this one! I understand that envvars are all strings, but I think it's fine to set a non-string default when they're missing, right? Is there a PEP or Ruff rule about this?

@cyyever
Copy link
Contributor Author

cyyever commented Aug 6, 2025

Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

In that case, I think we can enable it! I took another look and most of the fixes seem sensible to me.

Comment on lines +216 to +217
"sm_number_gpu": os.getenv("SM_NUM_GPUS", "0"),
"sm_number_cpu": os.getenv("SM_NUM_CPUS", "0"),
Copy link
Member

Choose a reason for hiding this comment

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

This case actually does fix an inconsistency - the return value is an int when the envvar isn't set and a string otherwise. In most other cases the default value is inside an int() call anyway

@Rocketknight1 Rocketknight1 enabled auto-merge (squash) August 7, 2025 17:12
@Rocketknight1 Rocketknight1 merged commit 9bfbdd2 into huggingface:main Aug 7, 2025
24 checks passed
@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.

@cyyever cyyever deleted the pl_test2 branch August 7, 2025 23:37
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