Skip to content

Commit

Permalink
add workarounf for git_lfs 413 request entity too large issue [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
swistakm committed May 20, 2019
1 parent 21fbc66 commit 2c12ac5
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions doc/source/conf.py
Expand Up @@ -18,6 +18,9 @@
#
import os
import sys
import logging

logger = logging.getLogger(__name__)

DOC_SOURCES_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT_DIR = os.path.dirname(os.path.dirname(DOC_SOURCES_DIR))
Expand All @@ -35,8 +38,31 @@
render_examples = False

# hack for lacking git-lfs support on rtd
from git_lfs import fetch
fetch(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
import git_lfs
try:
from urllib.error import HTTPError
except ImportError:
from urllib2 import HTTPError

_fetch_urls = git_lfs.fetch_urls

def _patched_fetch_urls(lfs_url, oid_list):
"""Hack git_lfs library that sometimes makes too big requests"""
objects = []

try:
objects.extend(_fetch_urls(lfs_url, oid_list))
except HTTPError as err:
if err.code != 413:
raise
logger.error("LFS: request entity too large, splitting in half")
objects.extend(_patched_fetch_urls(lfs_url, oid_list[:len(oid_list) // 2]))
objects.extend(_patched_fetch_urls(lfs_url, oid_list[len(oid_list) // 2:]))

return objects

git_lfs.fetch_urls = _patched_fetch_urls
git_lfs.fetch(PROJECT_ROOT_DIR)

else:
render_examples = True
Expand Down

0 comments on commit 2c12ac5

Please sign in to comment.