github.com/pachyderm/pachyderm@v1.13.4/examples/opencv/goclient-example/opencv-example.go (about)

     1  package main
     2  
     3  // This is an OpenCV example written in Go. Run this file
     4  // from the root of the repo. You must have a working
     5  // Pachyderm cluster running on your machine to run this
     6  // example.
     7  
     8  import (
     9  	"fmt"
    10  	"github.com/pachyderm/pachyderm/src/client"
    11  	"github.com/pachyderm/pachyderm/src/client/pfs"
    12  	"github.com/pachyderm/pachyderm/src/client/pps"
    13  	//	"os"
    14  )
    15  
    16  func main() {
    17  
    18  	// Replace the IP address with your `pachd` address.
    19  	// If running in minikube, this will be your minikube
    20  	// IP.
    21  	c, err := client.NewFromAddress("localhost:30650")
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  
    26  	if _, err := c.PfsAPIClient.CreateRepo(
    27  		c.Ctx(),
    28  		&pfs.CreateRepoRequest{
    29  			Repo:        client.NewRepo("images"),
    30  			Description: "An images repo",
    31  			Update:      true,
    32  		},
    33  	); err != nil {
    34  		panic(err)
    35  	}
    36  
    37  	if err := c.PutFileURL("images", "master", "liberty.png", "http://imgur.com/46Q8nDz.png", false, false); err != nil {
    38  		panic(err)
    39  	}
    40  
    41  	if err := c.PutFileURL("images", "master", "AT-AT.png", "http://imgur.com/8MN9Kg0.png", false, false); err != nil {
    42  		panic(err)
    43  	}
    44  
    45  	if err := c.PutFileURL("images", "master", "kitten.png", "http://imgur.com/g2QnNqa.png", false, false); err != nil {
    46  		panic(err)
    47  	}
    48  
    49  	defer func() {
    50  		if err := c.Close(); err != nil {
    51  			panic(err)
    52  		}
    53  	}()
    54  
    55  	files, err := c.ListFile("images", "master", "/")
    56  	if err != nil {
    57  		panic(err)
    58  	}
    59  	fmt.Println(files)
    60  
    61  	if err := c.CreatePipeline(
    62  		"edges",
    63  		"pachyderm/opencv",
    64  		[]string{"python3", "/edges.py"},
    65  		[]string{},
    66  		&pps.ParallelismSpec{
    67  			Constant: 1,
    68  		},
    69  		client.NewPFSInput("images", "/*"),
    70  		"",
    71  		false,
    72  	); err != nil {
    73  		panic(err)
    74  	}
    75  
    76  	if err := c.CreatePipeline(
    77  		"montage",
    78  		"v4tech/imagemagick",
    79  		[]string{"sh"},
    80  		[]string{
    81  			"montage -shadow -background SkyBlue -geometry 300x300+2+2 $(find /pfs -type f | sort) /pfs/out/montage.png",
    82  		},
    83  		&pps.ParallelismSpec{
    84  			Constant: 1,
    85  		},
    86  		client.NewCrossInput(
    87  			client.NewPFSInput("images", "/"),
    88  			client.NewPFSInput("edges", "/"),
    89  		),
    90  		"",
    91  		false,
    92  	); err != nil {
    93  		panic(err)
    94  	}
    95  
    96  	pipelines, err := c.ListPipeline()
    97  	if err != nil {
    98  		panic(err)
    99  	}
   100  	fmt.Println(pipelines)
   101  }