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
Example #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.
    """
        # TODO(b/31062835): remove CloneAndSwitchAPI and extract API code to api_lib
        client = apis.GetClientInstance('ml', 'v1beta1')
        msgs = apis.GetMessagesModule('ml', 'v1beta1')
        reg = resources.REGISTRY.CloneAndSwitchAPIs(client)
        res = reg.Parse(args.version,
                        params={'modelsId': args.model},
                        collection='ml.projects.models.versions')
        req = msgs.MlProjectsModelsVersionsCreateRequest(
            projectsId=res.projectsId,
            modelsId=res.modelsId,
            googleCloudMlV1beta1Version=msgs.GoogleCloudMlV1beta1Version(
                name=res.Name(), deploymentUri=args.origin))
        op = client.projects_models_versions.Create(req)
        if args. async:
            return op
        with console_io.ProgressTracker('Creating version...'):
            operations.WaitForOperation(client.projects_operations,
                                        op,
                                        registry=reg)
        return op.response
Example #3
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.
    """
        client = apis.GetClientInstance('ml', 'v1alpha3')
        msgs = apis.GetMessagesModule('ml', 'v1alpha3')
        res = resources.REGISTRY.Parse(
            args.version,
            params={'modelsId': args.model},
            collection='ml.projects.models.versions')
        req = msgs.MlProjectsModelsCreateVersionRequest(
            projectsId=res.projectsId,
            modelsId=res.modelsId,
            googleCloudMlV1alpha3Version=msgs.GoogleCloudMlV1alpha3Version(
                name=res.Name(), originUri=args.origin))
        op = client.projects_models.CreateVersion(req)
        if args. async:
            return op
        with console_io.ProgressTracker('Creating version...'):
            operations.WaitForOperation(client.projects_operations, op)
        return op.response
Example #4
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.
    """
        op = models.Delete(args.model)
        client = apis.GetClientInstance('ml', 'v1beta1')

        with progress_tracker.ProgressTracker('Deleting model...'):
            operations.WaitForOperation(client.projects_operations, op)
        return op.response
Example #5
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.
    """
        op = versions.Create(args.model, args.version, args.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
Example #6
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.
    """
        config = jobs.BuildTrainingConfig(path=args.config,
                                          module_name=args.module,
                                          job_name=args.job,
                                          trainer_uri=args.trainer_uri)
        op = jobs.Train(config)
        if args. async:
            return op
        return operations.WaitForOperation(
            apis.GetClientInstance('ml', 'v1alpha3').projects_operations, op)