This repository was archived by the owner on Oct 21, 2022. It is now read-only.
Shallow clone the github head version for client libs#243
Merged
liyanhui1228 merged 1 commit intoGoogleCloudPlatform:masterfrom Feb 12, 2019
Merged
Shallow clone the github head version for client libs#243liyanhui1228 merged 1 commit intoGoogleCloudPlatform:masterfrom
liyanhui1228 merged 1 commit intoGoogleCloudPlatform:masterfrom
Conversation
wangxf123456
approved these changes
Feb 12, 2019
| PYPI_URL = 'https://pypi.org/pypi/' | ||
| CONTAINER_WITH_PKG = "checker" | ||
| TIME_OUT = 300 # seconds | ||
| GITHUB_CLIENTLIBS_PREFIX = 'git+git://github.com/googleapis/' \ |
Contributor
There was a problem hiding this comment.
Is this really called client libs? I thought that was https://github.com/googleapis/google-api-python-client
Member
Author
There was a problem hiding this comment.
It's https://github.com/googleapis/google-cloud-python actually, I just call it clientlibs for short. That one is the discovery based APIs.
| output) | ||
| # If there is cloud client libraries, install it from source. | ||
| # Else install it from PyPI. | ||
| for pkg in self._packages: |
Contributor
There was a problem hiding this comment.
I'd structure this a bit differently to make it more readable.
def _clone_repo(self, container, repo):
"""<docstring>"""
_, directory = self._run_command(
container,
"echo $(mktemp -d)"
stderr=False,
stdout=True,
raise_on_failure=True)
shallow_clone_command = ['git', 'clone', '--depth', '1', repo, directory]
self._run_command(
container,
shallow_clone_command,
stdout=False,
stderr=True,
raise_on_failure=True)
return directory
def _install(self, container: docker.models.containers.Container):
if any(GITHUB_CLIENTLIBS_PREFIX in pkg for pkg in self._packages):
# The https://github.com/googleapis/google-cloud-python repository is large,
# has a large amount of history and contains many independent packages.
# Installing packages from that repository is quite slow e.g.
# $ time pip install git+git://...
# <result>
# As an optimization, if any provided package is installed from this repository,
# it is first cloned (using --depth=1 to avoid unnecessary history) and then
# installed from local disk e.g.
# $ time git clone --depth=1 ... && pip install ...
# <result>
client_repo_directory = self._clone_repo(CLIENTLIBS_GITHUB_URL)
install_names = []
for pkg in self._packages:
if GITHUB_CLIENTLIBS_PREFIX in pkg:
install_subdirectory = pkg.split(GITHUB_CLIENTLIBS_PREFIX)[1]
install_names.append(os.path.join(client_repo_directory, install_subdirectory))
else:
install_names.append(pkg)
command = self._build_command(['install', '-U'] + install_names)
# Rest is the same.| # Shallow clone the repository | ||
| shallow_clone_command = ['git', 'clone', '--depth', '1', | ||
| CLIENTLIBS_GITHUB_URL] | ||
| self._run_command( |
Contributor
There was a problem hiding this comment.
I don't like that we can run this multiple times and every time after the first will fail. I also don't like that we don't check for failures.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An alternative for #241