mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-04 05:10:06 +06:00
improve dev setup comments and hints (#28495)
* improve dev setup comments and hints * fix tests for new dev setup hints
This commit is contained in:
parent
735968b61c
commit
ff86bc364d
@ -26,7 +26,7 @@ from transformers.testing_utils import HfDoctestModule, HfDocTestParser
|
|||||||
|
|
||||||
|
|
||||||
# allow having multiple repository checkouts and not needing to remember to rerun
|
# allow having multiple repository checkouts and not needing to remember to rerun
|
||||||
# 'pip install -e .[dev]' when switching between checkouts and running tests.
|
# `pip install -e '.[dev]'` when switching between checkouts and running tests.
|
||||||
git_repo_path = abspath(join(dirname(__file__), "src"))
|
git_repo_path = abspath(join(dirname(__file__), "src"))
|
||||||
sys.path.insert(1, git_repo_path)
|
sys.path.insert(1, git_repo_path)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from os.path import abspath, dirname, join
|
|||||||
|
|
||||||
|
|
||||||
# allow having multiple repository checkouts and not needing to remember to rerun
|
# allow having multiple repository checkouts and not needing to remember to rerun
|
||||||
# 'pip install -e .[dev]' when switching between checkouts and running tests.
|
# `pip install -e '.[dev]'` when switching between checkouts and running tests.
|
||||||
git_repo_path = abspath(join(dirname(dirname(dirname(__file__))), "src"))
|
git_repo_path = abspath(join(dirname(dirname(dirname(__file__))), "src"))
|
||||||
sys.path.insert(1, git_repo_path)
|
sys.path.insert(1, git_repo_path)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from os.path import abspath, dirname, join
|
|||||||
|
|
||||||
|
|
||||||
# allow having multiple repository checkouts and not needing to remember to rerun
|
# allow having multiple repository checkouts and not needing to remember to rerun
|
||||||
# 'pip install -e .[dev]' when switching between checkouts and running tests.
|
# `pip install -e '.[dev]'` when switching between checkouts and running tests.
|
||||||
git_repo_path = abspath(join(dirname(dirname(dirname(__file__))), "src"))
|
git_repo_path = abspath(join(dirname(dirname(dirname(__file__))), "src"))
|
||||||
sys.path.insert(1, git_repo_path)
|
sys.path.insert(1, git_repo_path)
|
||||||
|
|
||||||
|
@ -113,5 +113,5 @@ def require_version(requirement: str, hint: Optional[str] = None) -> None:
|
|||||||
|
|
||||||
def require_version_core(requirement):
|
def require_version_core(requirement):
|
||||||
"""require_version wrapper which emits a core-specific hint on failure"""
|
"""require_version wrapper which emits a core-specific hint on failure"""
|
||||||
hint = "Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git main"
|
hint = "Try: `pip install transformers -U` or `pip install -e '.[dev]'` if you're working with git main"
|
||||||
return require_version(requirement, hint)
|
return require_version(requirement, hint)
|
||||||
|
@ -68,7 +68,7 @@ class DependencyVersionCheckTest(TestCasePlus):
|
|||||||
require_version_core(req)
|
require_version_core(req)
|
||||||
except importlib.metadata.PackageNotFoundError as e:
|
except importlib.metadata.PackageNotFoundError as e:
|
||||||
self.assertIn(f"The '{req}' distribution was not found and is required by this application", str(e))
|
self.assertIn(f"The '{req}' distribution was not found and is required by this application", str(e))
|
||||||
self.assertIn("Try: pip install transformers -U", str(e))
|
self.assertIn("Try: `pip install transformers -U`", str(e))
|
||||||
|
|
||||||
# bogus requirements formats:
|
# bogus requirements formats:
|
||||||
# 1. whole thing
|
# 1. whole thing
|
||||||
|
@ -358,12 +358,12 @@ def check_missing_backends():
|
|||||||
missing = ", ".join(missing_backends)
|
missing = ", ".join(missing_backends)
|
||||||
if os.getenv("TRANSFORMERS_IS_CI", "").upper() in ENV_VARS_TRUE_VALUES:
|
if os.getenv("TRANSFORMERS_IS_CI", "").upper() in ENV_VARS_TRUE_VALUES:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Full repo consistency checks require all backends to be installed (with `pip install -e .[dev]` in the "
|
"Full repo consistency checks require all backends to be installed (with `pip install -e '.[dev]'` in the "
|
||||||
f"Transformers repo, the following are missing: {missing}."
|
f"Transformers repo, the following are missing: {missing}."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"Full repo consistency checks require all backends to be installed (with `pip install -e .[dev]` in the "
|
"Full repo consistency checks require all backends to be installed (with `pip install -e '.[dev]'` in the "
|
||||||
f"Transformers repo, the following are missing: {missing}. While it's probably fine as long as you "
|
f"Transformers repo, the following are missing: {missing}. While it's probably fine as long as you "
|
||||||
"didn't make any change in one of those backends modeling files, you should probably execute the "
|
"didn't make any change in one of those backends modeling files, you should probably execute the "
|
||||||
"command above to be on the safe side."
|
"command above to be on the safe side."
|
||||||
|
Loading…
Reference in New Issue
Block a user