This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speed-ups (shasum + poetry install caching) (#91)
* Add command to lazy get the sha1 command * Remove duplicated function * Simplify yarn command detection * Speed up poetry install Two timings when updating version number in libs/api: Before poetry cache: 59/57 seconds After poetry cache: 31/30 seconds * Use the fastest shasum available (30% speedup) * Log error if hashing takes more than 3 seconds * Disable pylint warning (we like globals) * Update docstring
- Loading branch information
Showing
3 changed files
with
47 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import subprocess | ||
|
||
from .logger import logger | ||
|
||
_sha1_command = None | ||
|
||
|
||
def run_shell_command(cmd: str, cwd: str = None) -> str: | ||
return subprocess.check_output(cmd, shell=True, encoding="utf8", cwd=cwd).rstrip("\n") | ||
|
||
|
||
def get_sha1_command() -> str: | ||
"""Returns the fastest sha1sum command supported by the system""" | ||
# pylint: disable=global-statement | ||
global _sha1_command | ||
if not _sha1_command: | ||
try: | ||
run_shell_command("which sha1sum") | ||
_sha1_command = "sha1sum" | ||
except subprocess.CalledProcessError: | ||
logger.info("sha1sum not found on this system (performance will be slightly degraded)") | ||
_sha1_command = "shasum" | ||
return _sha1_command |