mirror of
https://github.com/clearml/clearml
synced 2025-02-07 21:33:25 +00:00
Add better input handling for clearml-init in colab (#515)
This commit is contained in:
parent
dedf31867a
commit
24464b7c10
@ -67,6 +67,15 @@ def main():
|
|||||||
print(description, end='')
|
print(description, end='')
|
||||||
sentinel = ''
|
sentinel = ''
|
||||||
parse_input = ''
|
parse_input = ''
|
||||||
|
# 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):
|
for line in iter(input, sentinel):
|
||||||
parse_input += line+'\n'
|
parse_input += line+'\n'
|
||||||
if line.rstrip() == '}':
|
if line.rstrip() == '}':
|
||||||
|
Loading…
Reference in New Issue
Block a user