in perfzero/lib/cloud_manager.py [0:0]
def parse_arguments(argv, command): # pylint: disable=redefined-outer-name
"""Parse command line arguments and return parsed flags.
Args:
argv: command line arguments
command: the subcommand requested by the user
Returns:
parsed flags
"""
# pylint: disable=redefined-outer-name
parser = argparse.ArgumentParser(
usage='cloud_manager.py {} [<args>]'.format(command),
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'--debug',
action='store_true',
help='If set, use debug level logging. Otherwise, use info level logging'
)
parser.add_argument(
'--project',
default='google.com:tensorflow-performance',
type=str,
help='Google Cloud Platform project name to use for this invocation'
)
if command in ['create', 'start', 'stop', 'delete', 'status']:
parser.add_argument(
'--username',
default=getpass.getuser(),
type=str,
help='''Username that uniquely identifies the name of computing instance created for PerfZero.
The default value is your ldap username.
''')
parser.add_argument(
'--zone',
default='us-west1-b',
type=str,
help='Zone of the instance to create.'
)
parser.add_argument(
'--ssh-internal-ip',
action='store_true',
help='If set, use internal IP for ssh with `gcloud beta compute ssh`.'
)
parser.add_argument(
'--ssh-key-file',
default=None,
type=str,
help='The ssh key to use with with `gcloud (beta) compute ssh`.'
)
if command == 'create':
parser.add_argument(
'--accelerator_count',
default=1,
type=int,
help='The number of pieces of the accelerator to attach to the instance'
)
parser.add_argument(
'--accelerator_type',
default='nvidia-tesla-v100',
type=str,
help='''The specific type (e.g. nvidia-tesla-v100 for nVidia Tesla V100) of
accelerator to attach to the instance. Use 'gcloud compute accelerator-types list --project=${project_name}' to
learn about all available accelerator types.
''')
parser.add_argument(
'--cpu_min_platform',
default=None,
type=str,
help='''Minimum cpu platform, only needed for CPU only instances.''')
parser.add_argument(
'--machine_type',
default=None,
type=str,
help='''The machine type used for the instance. To get a list of available machine
types, run 'gcloud compute machine-types list --project=${project_name}'
''')
parser.add_argument(
'--image',
default='tf-ubuntu-1604-20180927-410',
type=str,
help='''Specifies the name of the image that the disk will be initialized with.
A new disk will be created based on the given image. To view a list of
public images and projects, run 'gcloud compute images list --project=${project_name}'. It is best
practice to use image when a specific version of an image is needed.
''')
parser.add_argument(
'--nvme_count',
default=0,
type=int,
help='''Specifies the number of NVME local SSD devices to attach to the instance.
'''
)
parser.add_argument(
'--boot_ssd_size',
default=None,
type=int,
help='''Specifies the size (GB) of the boot disk or size is the image
size. Setting this also changes boot disk to Persistent SSD.
'''
)
flags, unparsed = parser.parse_known_args(argv) # pylint: disable=redefined-outer-name
if unparsed:
logging.error('Arguments %s are not recognized', unparsed)
sys.exit(1)
level = logging.DEBUG if flags.debug else logging.INFO
logging.basicConfig(format='%(message)s', level=level)
return flags