Add better input handling for clearml-init in colab (#515)

This commit is contained in:
Victor Sonck 2021-12-14 19:49:34 +01:00 committed by GitHub
parent dedf31867a
commit 24464b7c10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,10 +67,19 @@ def main():
print(description, end='')
sentinel = ''
parse_input = ''
for line in iter(input, sentinel):
parse_input += line+'\n'
if line.rstrip() == '}':
break
# COLAB_GPU will always be available, even when running on CPU
if os.environ.get('COLAB_GPU'):
# When running from a colab instance and calling clearml-init
# colab will squish the api credentials into a single line
# The regex splits this single line based on 2 spaces or more
import re
api_input = input()
parse_input = '\n'.join(re.split(r" {2,}", api_input))
else:
for line in iter(input, sentinel):
parse_input += line+'\n'
if line.rstrip() == '}':
break
credentials = None
api_server = None
web_server = None