Beispiel #1
0
def _AddSubmitTrainingArgs(parser):
  """Add arguments for `jobs submit training` command."""
  flags.JOB_NAME.AddToParser(parser)
  flags.PACKAGE_PATH.AddToParser(parser)
  flags.PACKAGES.AddToParser(parser)
  flags.GetModuleNameFlag(required=False).AddToParser(parser)
  compute_flags.AddRegionFlag(parser, 'machine learning training job',
                              'submit')
  flags.CONFIG.AddToParser(parser)
  flags.STAGING_BUCKET.AddToParser(parser)
  flags.GetJobDirFlag(upload_help=True).AddToParser(parser)
  flags.GetUserArgs(local=False).AddToParser(parser)
  jobs_util.ScaleTierFlagMap().choice_arg.AddToParser(parser)
  flags.RUNTIME_VERSION.AddToParser(parser)
  flags.AddPythonVersionFlag(parser, 'during training')

  sync_group = parser.add_mutually_exclusive_group()
  # TODO(b/36195821): Use the flag deprecation machinery when it supports the
  # store_true action
  sync_group.add_argument(
      '--async', action='store_true', help=(
          '(DEPRECATED) Display information about the operation in progress '
          'without waiting for the operation to complete. '
          'Enabled by default and can be omitted; use `--stream-logs` to run '
          'synchronously.'))
  sync_group.add_argument(
      '--stream-logs',
      action='store_true',
      help=('Block until job completion and stream the logs while the job runs.'
            '\n\n'
            'Note that even if command execution is halted, the job will still '
            'run until cancelled with\n\n'
            '    $ gcloud ai-platform jobs cancel JOB_ID'))
  labels_util.AddCreateLabelsFlags(parser)
Beispiel #2
0
def _AddCreateArgs(parser):
    """Add common arguments for `versions create` command."""
    flags.GetModelName(positional=False, required=True).AddToParser(parser)
    flags.GetDescriptionFlag('version').AddToParser(parser)
    flags.GetRegionArg(include_global=True).AddToParser(parser)
    flags.VERSION_NAME.AddToParser(parser)
    base.Argument('--origin',
                  help="""\
          Location of ```model/``` "directory" (see
          https://cloud.google.com/ai-platform/prediction/docs/deploying-models#upload-model).

          This overrides `deploymentUri` in the `--config` file. If this flag is
          not passed, `deploymentUri` *must* be specified in the file from
          `--config`.

          Can be a Cloud Storage (`gs://`) path or local file path (no
          prefix). In the latter case the files will be uploaded to Cloud
          Storage and a `--staging-bucket` argument is required.
      """).AddToParser(parser)
    flags.RUNTIME_VERSION.AddToParser(parser)
    base.ASYNC_FLAG.AddToParser(parser)
    flags.STAGING_BUCKET.AddToParser(parser)
    base.Argument('--config',
                  help="""\
          Path to a YAML configuration file containing configuration parameters
          for the
          [Version](https://cloud.google.com/ai-platform/prediction/docs/reference/rest/v1/projects.models.versions)
          to create.

          The file is in YAML format. Note that not all attributes of a version
          are configurable; available attributes (with example values) are:

              description: A free-form description of the version.
              deploymentUri: gs://path/to/source
              runtimeVersion: '2.1'
              #  Set only one of either manualScaling or autoScaling.
              manualScaling:
                nodes: 10  # The number of nodes to allocate for this model.
              autoScaling:
                minNodes: 0  # The minimum number of nodes to allocate for this model.
              labels:
                user-defined-key: user-defined-value

          The name of the version must always be specified via the required
          VERSION argument.

          Only one of manualScaling or autoScaling can be specified. If both
          are specified in same yaml file an error will be returned.

          If an option is specified both in the configuration file and via
          command-line arguments, the command-line arguments override the
          configuration file.
      """).AddToParser(parser)
    labels_util.AddCreateLabelsFlags(parser)
    flags.FRAMEWORK_MAPPER.choice_arg.AddToParser(parser)
    flags.AddPythonVersionFlag(parser, 'when creating the version')
    flags.AddMachineTypeFlagToParser(parser)
    flags.GetAcceleratorFlag().AddToParser(parser)
    flags.AddAutoScalingFlags(parser)
Beispiel #3
0
 def Args(parser):
   _AddCreateArgs(parser)
   flags.MACHINE_TYPE.AddToParser(parser)
   flags.FRAMEWORK_MAPPER.choice_arg.AddToParser(parser)
   flags.AddPythonVersionFlag(parser, 'when creating the version')
Beispiel #4
0
 def Args(parser):
     _AddCreateArgs(parser)
     flags.ALPHA_MACHINE_TYPE.AddToParser(parser)
     flags.AddPythonVersionFlag(parser, 'when creating the version')