예제 #1
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
        try:
            origin = uploads.UploadDirectoryIfNecessary(
                args.origin, args.staging_bucket)
        except uploads.MissingStagingBucketException:
            raise InvalidArgumentCombinationError(
                'If --origin is provided as a local path, --staging-bucket must be '
                'given as well.')

        versions_client = versions_api.VersionsClient()
        model_ref = models_util.ParseModel(args.model)
        op = versions_client.Create(model_ref, args.version, origin,
                                    args.runtime_version)
        return versions_util.WaitForOpMaybe(
            op,
            async_=args. async,
            message='Creating version (this might take a few minutes)...')
예제 #2
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
        try:
            origin = uploads.UploadDirectoryIfNecessary(
                args.origin, args.staging_bucket)
        except uploads.MissingStagingBucketException:
            raise InvalidArgumentCombinationError(
                'If --origin is provided as a local path, --staging-bucket must be '
                'given as well.')

        op = versions.Create(args.model, args.version, origin)
        if args. async:
            return op

        client = apis.GetClientInstance('ml', 'v1beta1')
        with progress_tracker.ProgressTracker(
                'Creating version (this might take a few minutes)...'):
            operations.WaitForOperation(client.projects_operations, op)
        return op.response
예제 #3
0
def Create(versions_client, operations_client, version,
           model=None, origin=None, staging_bucket=None, runtime_version=None,
           async_=None):
  """Create a version, optionally waiting for creation to finish."""
  try:
    origin = uploads.UploadDirectoryIfNecessary(origin, staging_bucket)
  except uploads.MissingStagingBucketException:
    raise InvalidArgumentCombinationError(
        'If --origin is provided as a local path, --staging-bucket must be '
        'given as well.')

  model_ref = models_util.ParseModel(model)
  op = versions_client.Create(model_ref, version, origin, runtime_version)
  return WaitForOpMaybe(
      operations_client, op, async_=async_,
      message='Creating version (this might take a few minutes)...')