diff --git a/clearml/utilities/pigar/reqs.py b/clearml/utilities/pigar/reqs.py index 35560960..2f997d9d 100644 --- a/clearml/utilities/pigar/reqs.py +++ b/clearml/utilities/pigar/reqs.py @@ -406,19 +406,30 @@ def _search_path(path): # noinspection PyBroadException try: with open(git_direct_json, 'r') as f: - vcs_info = json.load(f) + direct_json = json.load(f) - if 'vcs_info' in vcs_info: + if 'vcs_info' in direct_json: + vcs_info = direct_json['vcs_info'] git_url = '{vcs}+{url}@{commit}#egg={package}'.format( - vcs=vcs_info['vcs_info']['vcs'], url=vcs_info['url'], - commit=vcs_info['vcs_info']['commit_id'], package=pkg_name) + vcs=vcs_info['vcs'], url=direct_json['url'], + commit=vcs_info['commit_id'], package=pkg_name) + # If subdirectory is present, append this to the git_url + if 'subdirectory' in direct_json: + git_url = '{git_url}&subdirectory={subdirectory}'.format( + git_url=git_url, subdirectory=direct_json['subdirectory']) # Bugfix: package name should be the URL link, because we need it unique # mapping[pkg_name] = ('-e', git_url) pkg_name, version = '-e {}'.format(git_url), '' - elif 'url' in vcs_info: - url_link = vcs_info.get('url', '').strip().lower() + elif 'url' in direct_json: + url_link = direct_json.get('url', '').strip().lower() if url_link and not url_link.startswith('file://'): - pkg_name, version = vcs_info['url'], '' + git_url = direct_json['url'] + # If subdirectory is present, append this to the git_url + if 'subdirectory' in direct_json: + git_url = '{git_url}#subdirectory={subdirectory}'.format( + git_url=direct_json['url'], subdirectory=direct_json['subdirectory']) + + pkg_name, version = git_url, '' except Exception: pass