repo
stringlengths 5
67
| path
stringlengths 4
218
| func_name
stringlengths 0
151
| original_string
stringlengths 52
373k
| language
stringclasses 6
values | code
stringlengths 52
373k
| code_tokens
listlengths 10
512
| docstring
stringlengths 3
47.2k
| docstring_tokens
listlengths 3
234
| sha
stringlengths 40
40
| url
stringlengths 85
339
| partition
stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
pachyderm/pachyderm
|
src/plugin/vault/pachyderm/renew.go
|
renewUserCredentials
|
func renewUserCredentials(ctx context.Context, pachdAddress string, adminToken string, userToken string, ttl time.Duration) error {
// Setup a single use client w the given admin token / address
client, err := pclient.NewFromAddress(pachdAddress)
if err != nil {
return err
}
defer client.Close() // avoid leaking connections
client = client.WithCtx(ctx)
client.SetAuthToken(adminToken)
_, err = client.AuthAPIClient.ExtendAuthToken(client.Ctx(), &auth.ExtendAuthTokenRequest{
Token: userToken,
TTL: int64(ttl.Seconds()),
})
if err != nil {
return err
}
return nil
}
|
go
|
func renewUserCredentials(ctx context.Context, pachdAddress string, adminToken string, userToken string, ttl time.Duration) error {
// Setup a single use client w the given admin token / address
client, err := pclient.NewFromAddress(pachdAddress)
if err != nil {
return err
}
defer client.Close() // avoid leaking connections
client = client.WithCtx(ctx)
client.SetAuthToken(adminToken)
_, err = client.AuthAPIClient.ExtendAuthToken(client.Ctx(), &auth.ExtendAuthTokenRequest{
Token: userToken,
TTL: int64(ttl.Seconds()),
})
if err != nil {
return err
}
return nil
}
|
[
"func",
"renewUserCredentials",
"(",
"ctx",
"context",
".",
"Context",
",",
"pachdAddress",
"string",
",",
"adminToken",
"string",
",",
"userToken",
"string",
",",
"ttl",
"time",
".",
"Duration",
")",
"error",
"{",
"client",
",",
"err",
":=",
"pclient",
".",
"NewFromAddress",
"(",
"pachdAddress",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"client",
".",
"Close",
"(",
")",
"\n",
"client",
"=",
"client",
".",
"WithCtx",
"(",
"ctx",
")",
"\n",
"client",
".",
"SetAuthToken",
"(",
"adminToken",
")",
"\n",
"_",
",",
"err",
"=",
"client",
".",
"AuthAPIClient",
".",
"ExtendAuthToken",
"(",
"client",
".",
"Ctx",
"(",
")",
",",
"&",
"auth",
".",
"ExtendAuthTokenRequest",
"{",
"Token",
":",
"userToken",
",",
"TTL",
":",
"int64",
"(",
"ttl",
".",
"Seconds",
"(",
")",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// renewUserCredentials extends the TTL of the Pachyderm authentication token
// 'userToken', using the vault plugin's Admin credentials. 'userToken' belongs
// to the user who is calling vault, and would like to extend their Pachyderm
// session.
|
[
"renewUserCredentials",
"extends",
"the",
"TTL",
"of",
"the",
"Pachyderm",
"authentication",
"token",
"userToken",
"using",
"the",
"vault",
"plugin",
"s",
"Admin",
"credentials",
".",
"userToken",
"belongs",
"to",
"the",
"user",
"who",
"is",
"calling",
"vault",
"and",
"would",
"like",
"to",
"extend",
"their",
"Pachyderm",
"session",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/plugin/vault/pachyderm/renew.go#L71-L92
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/local_client.go
|
NewLocalClient
|
func NewLocalClient(root string) (Client, error) {
if err := os.MkdirAll(root, 0755); err != nil {
return nil, err
}
return &localClient{root}, nil
}
|
go
|
func NewLocalClient(root string) (Client, error) {
if err := os.MkdirAll(root, 0755); err != nil {
return nil, err
}
return &localClient{root}, nil
}
|
[
"func",
"NewLocalClient",
"(",
"root",
"string",
")",
"(",
"Client",
",",
"error",
")",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"root",
",",
"0755",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"localClient",
"{",
"root",
"}",
",",
"nil",
"\n",
"}"
] |
// NewLocalClient returns a Client that stores data on the local file system
|
[
"NewLocalClient",
"returns",
"a",
"Client",
"that",
"stores",
"data",
"on",
"the",
"local",
"file",
"system"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/local_client.go#L12-L17
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
AddSpanToAnyExisting
|
func AddSpanToAnyExisting(ctx context.Context, operation string, kvs ...interface{}) (opentracing.Span, context.Context) {
if parentSpan := opentracing.SpanFromContext(ctx); parentSpan != nil {
span := opentracing.StartSpan(operation, opentracing.ChildOf(parentSpan.Context()))
tagSpan(span, kvs)
return span, opentracing.ContextWithSpan(ctx, span)
}
return nil, ctx
}
|
go
|
func AddSpanToAnyExisting(ctx context.Context, operation string, kvs ...interface{}) (opentracing.Span, context.Context) {
if parentSpan := opentracing.SpanFromContext(ctx); parentSpan != nil {
span := opentracing.StartSpan(operation, opentracing.ChildOf(parentSpan.Context()))
tagSpan(span, kvs)
return span, opentracing.ContextWithSpan(ctx, span)
}
return nil, ctx
}
|
[
"func",
"AddSpanToAnyExisting",
"(",
"ctx",
"context",
".",
"Context",
",",
"operation",
"string",
",",
"kvs",
"...",
"interface",
"{",
"}",
")",
"(",
"opentracing",
".",
"Span",
",",
"context",
".",
"Context",
")",
"{",
"if",
"parentSpan",
":=",
"opentracing",
".",
"SpanFromContext",
"(",
"ctx",
")",
";",
"parentSpan",
"!=",
"nil",
"{",
"span",
":=",
"opentracing",
".",
"StartSpan",
"(",
"operation",
",",
"opentracing",
".",
"ChildOf",
"(",
"parentSpan",
".",
"Context",
"(",
")",
")",
")",
"\n",
"tagSpan",
"(",
"span",
",",
"kvs",
")",
"\n",
"return",
"span",
",",
"opentracing",
".",
"ContextWithSpan",
"(",
"ctx",
",",
"span",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"ctx",
"\n",
"}"
] |
// AddSpanToAnyExisting checks 'ctx' for Jaeger tracing information, and if
// tracing metadata is present, it generates a new span for 'operation', marks
// it as a child of the existing span, and returns it.
|
[
"AddSpanToAnyExisting",
"checks",
"ctx",
"for",
"Jaeger",
"tracing",
"information",
"and",
"if",
"tracing",
"metadata",
"is",
"present",
"it",
"generates",
"a",
"new",
"span",
"for",
"operation",
"marks",
"it",
"as",
"a",
"child",
"of",
"the",
"existing",
"span",
"and",
"returns",
"it",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L57-L64
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
InstallJaegerTracerFromEnv
|
func InstallJaegerTracerFromEnv() {
jaegerOnce.Do(func() {
jaegerEndpoint, onUserMachine := os.LookupEnv(jaegerEndpointEnvVar)
if !onUserMachine {
if host, ok := os.LookupEnv("JAEGER_COLLECTOR_SERVICE_HOST"); ok {
port := os.Getenv("JAEGER_COLLECTOR_SERVICE_PORT_JAEGER_COLLECTOR_HTTP")
jaegerEndpoint = fmt.Sprintf("%s:%s", host, port)
}
}
if jaegerEndpoint == "" {
return // break early -- not using Jaeger
}
// canonicalize jaegerEndpoint as http://<hostport>/api/traces
jaegerEndpoint = strings.TrimPrefix(jaegerEndpoint, "http://")
jaegerEndpoint = strings.TrimSuffix(jaegerEndpoint, "/api/traces")
jaegerEndpoint = fmt.Sprintf("http://%s/api/traces", jaegerEndpoint)
cfg := jaegercfg.Configuration{
// Configure Jaeger to sample every call, but use the SpanInclusionFunc
// addTraceIfTracingEnabled (defined below) to skip sampling every RPC
// unless the PACH_ENABLE_TRACING environment variable is set
Sampler: &jaegercfg.SamplerConfig{
Type: "const",
Param: 1,
},
Reporter: &jaegercfg.ReporterConfig{
LogSpans: true,
BufferFlushInterval: 1 * time.Second,
CollectorEndpoint: jaegerEndpoint,
},
}
// configure jaeger logger
logger := jaeger.Logger(jaeger.NullLogger)
if !onUserMachine {
logger = jaeger.StdLogger
}
// Hack: ignore second argument (io.Closer) because the Jaeger
// implementation of opentracing.Tracer also implements io.Closer (i.e. the
// first and second return values from cfg.New(), here, are two interfaces
// that wrap the same underlying type). Instead of storing the second return
// value here, just cast the tracer to io.Closer in CloseAndReportTraces()
// (below) and call 'Close()' on it there.
tracer, _, err := cfg.New(JaegerServiceName, jaegercfg.Logger(logger))
if err != nil {
panic(fmt.Sprintf("could not install Jaeger tracer: %v", err))
}
opentracing.SetGlobalTracer(tracer)
})
}
|
go
|
func InstallJaegerTracerFromEnv() {
jaegerOnce.Do(func() {
jaegerEndpoint, onUserMachine := os.LookupEnv(jaegerEndpointEnvVar)
if !onUserMachine {
if host, ok := os.LookupEnv("JAEGER_COLLECTOR_SERVICE_HOST"); ok {
port := os.Getenv("JAEGER_COLLECTOR_SERVICE_PORT_JAEGER_COLLECTOR_HTTP")
jaegerEndpoint = fmt.Sprintf("%s:%s", host, port)
}
}
if jaegerEndpoint == "" {
return // break early -- not using Jaeger
}
// canonicalize jaegerEndpoint as http://<hostport>/api/traces
jaegerEndpoint = strings.TrimPrefix(jaegerEndpoint, "http://")
jaegerEndpoint = strings.TrimSuffix(jaegerEndpoint, "/api/traces")
jaegerEndpoint = fmt.Sprintf("http://%s/api/traces", jaegerEndpoint)
cfg := jaegercfg.Configuration{
// Configure Jaeger to sample every call, but use the SpanInclusionFunc
// addTraceIfTracingEnabled (defined below) to skip sampling every RPC
// unless the PACH_ENABLE_TRACING environment variable is set
Sampler: &jaegercfg.SamplerConfig{
Type: "const",
Param: 1,
},
Reporter: &jaegercfg.ReporterConfig{
LogSpans: true,
BufferFlushInterval: 1 * time.Second,
CollectorEndpoint: jaegerEndpoint,
},
}
// configure jaeger logger
logger := jaeger.Logger(jaeger.NullLogger)
if !onUserMachine {
logger = jaeger.StdLogger
}
// Hack: ignore second argument (io.Closer) because the Jaeger
// implementation of opentracing.Tracer also implements io.Closer (i.e. the
// first and second return values from cfg.New(), here, are two interfaces
// that wrap the same underlying type). Instead of storing the second return
// value here, just cast the tracer to io.Closer in CloseAndReportTraces()
// (below) and call 'Close()' on it there.
tracer, _, err := cfg.New(JaegerServiceName, jaegercfg.Logger(logger))
if err != nil {
panic(fmt.Sprintf("could not install Jaeger tracer: %v", err))
}
opentracing.SetGlobalTracer(tracer)
})
}
|
[
"func",
"InstallJaegerTracerFromEnv",
"(",
")",
"{",
"jaegerOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"jaegerEndpoint",
",",
"onUserMachine",
":=",
"os",
".",
"LookupEnv",
"(",
"jaegerEndpointEnvVar",
")",
"\n",
"if",
"!",
"onUserMachine",
"{",
"if",
"host",
",",
"ok",
":=",
"os",
".",
"LookupEnv",
"(",
"\"JAEGER_COLLECTOR_SERVICE_HOST\"",
")",
";",
"ok",
"{",
"port",
":=",
"os",
".",
"Getenv",
"(",
"\"JAEGER_COLLECTOR_SERVICE_PORT_JAEGER_COLLECTOR_HTTP\"",
")",
"\n",
"jaegerEndpoint",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"%s:%s\"",
",",
"host",
",",
"port",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"jaegerEndpoint",
"==",
"\"\"",
"{",
"return",
"\n",
"}",
"\n",
"jaegerEndpoint",
"=",
"strings",
".",
"TrimPrefix",
"(",
"jaegerEndpoint",
",",
"\"http://\"",
")",
"\n",
"jaegerEndpoint",
"=",
"strings",
".",
"TrimSuffix",
"(",
"jaegerEndpoint",
",",
"\"/api/traces\"",
")",
"\n",
"jaegerEndpoint",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"http://%s/api/traces\"",
",",
"jaegerEndpoint",
")",
"\n",
"cfg",
":=",
"jaegercfg",
".",
"Configuration",
"{",
"Sampler",
":",
"&",
"jaegercfg",
".",
"SamplerConfig",
"{",
"Type",
":",
"\"const\"",
",",
"Param",
":",
"1",
",",
"}",
",",
"Reporter",
":",
"&",
"jaegercfg",
".",
"ReporterConfig",
"{",
"LogSpans",
":",
"true",
",",
"BufferFlushInterval",
":",
"1",
"*",
"time",
".",
"Second",
",",
"CollectorEndpoint",
":",
"jaegerEndpoint",
",",
"}",
",",
"}",
"\n",
"logger",
":=",
"jaeger",
".",
"Logger",
"(",
"jaeger",
".",
"NullLogger",
")",
"\n",
"if",
"!",
"onUserMachine",
"{",
"logger",
"=",
"jaeger",
".",
"StdLogger",
"\n",
"}",
"\n",
"tracer",
",",
"_",
",",
"err",
":=",
"cfg",
".",
"New",
"(",
"JaegerServiceName",
",",
"jaegercfg",
".",
"Logger",
"(",
"logger",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"could not install Jaeger tracer: %v\"",
",",
"err",
")",
")",
"\n",
"}",
"\n",
"opentracing",
".",
"SetGlobalTracer",
"(",
"tracer",
")",
"\n",
"}",
")",
"\n",
"}"
] |
// InstallJaegerTracerFromEnv installs a Jaeger client as then opentracing
// global tracer, relying on environment variables to configure the client. It
// returns the address used to initialize the global tracer, if any
// initialization occurred
|
[
"InstallJaegerTracerFromEnv",
"installs",
"a",
"Jaeger",
"client",
"as",
"then",
"opentracing",
"global",
"tracer",
"relying",
"on",
"environment",
"variables",
"to",
"configure",
"the",
"client",
".",
"It",
"returns",
"the",
"address",
"used",
"to",
"initialize",
"the",
"global",
"tracer",
"if",
"any",
"initialization",
"occurred"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L78-L128
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
UnaryClientInterceptor
|
func UnaryClientInterceptor() grpc.UnaryClientInterceptor {
return otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
go
|
func UnaryClientInterceptor() grpc.UnaryClientInterceptor {
return otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
[
"func",
"UnaryClientInterceptor",
"(",
")",
"grpc",
".",
"UnaryClientInterceptor",
"{",
"return",
"otgrpc",
".",
"OpenTracingClientInterceptor",
"(",
"opentracing",
".",
"GlobalTracer",
"(",
")",
",",
"otgrpc",
".",
"IncludingSpans",
"(",
"addTraceIfTracingEnabled",
")",
")",
"\n",
"}"
] |
// UnaryClientInterceptor returns a GRPC interceptor for non-streaming GRPC RPCs
|
[
"UnaryClientInterceptor",
"returns",
"a",
"GRPC",
"interceptor",
"for",
"non",
"-",
"streaming",
"GRPC",
"RPCs"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L161-L164
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
StreamClientInterceptor
|
func StreamClientInterceptor() grpc.StreamClientInterceptor {
return otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
go
|
func StreamClientInterceptor() grpc.StreamClientInterceptor {
return otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
[
"func",
"StreamClientInterceptor",
"(",
")",
"grpc",
".",
"StreamClientInterceptor",
"{",
"return",
"otgrpc",
".",
"OpenTracingStreamClientInterceptor",
"(",
"opentracing",
".",
"GlobalTracer",
"(",
")",
",",
"otgrpc",
".",
"IncludingSpans",
"(",
"addTraceIfTracingEnabled",
")",
")",
"\n",
"}"
] |
// StreamClientInterceptor returns a GRPC interceptor for non-streaming GRPC RPCs
|
[
"StreamClientInterceptor",
"returns",
"a",
"GRPC",
"interceptor",
"for",
"non",
"-",
"streaming",
"GRPC",
"RPCs"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L167-L170
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
UnaryServerInterceptor
|
func UnaryServerInterceptor() grpc.UnaryServerInterceptor {
return otgrpc.OpenTracingServerInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
go
|
func UnaryServerInterceptor() grpc.UnaryServerInterceptor {
return otgrpc.OpenTracingServerInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
[
"func",
"UnaryServerInterceptor",
"(",
")",
"grpc",
".",
"UnaryServerInterceptor",
"{",
"return",
"otgrpc",
".",
"OpenTracingServerInterceptor",
"(",
"opentracing",
".",
"GlobalTracer",
"(",
")",
",",
"otgrpc",
".",
"IncludingSpans",
"(",
"addTraceIfTracingEnabled",
")",
")",
"\n",
"}"
] |
// UnaryServerInterceptor returns a GRPC interceptor for non-streaming GRPC RPCs
|
[
"UnaryServerInterceptor",
"returns",
"a",
"GRPC",
"interceptor",
"for",
"non",
"-",
"streaming",
"GRPC",
"RPCs"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L173-L176
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
StreamServerInterceptor
|
func StreamServerInterceptor() grpc.StreamServerInterceptor {
return otgrpc.OpenTracingStreamServerInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
go
|
func StreamServerInterceptor() grpc.StreamServerInterceptor {
return otgrpc.OpenTracingStreamServerInterceptor(opentracing.GlobalTracer(),
otgrpc.IncludingSpans(addTraceIfTracingEnabled))
}
|
[
"func",
"StreamServerInterceptor",
"(",
")",
"grpc",
".",
"StreamServerInterceptor",
"{",
"return",
"otgrpc",
".",
"OpenTracingStreamServerInterceptor",
"(",
"opentracing",
".",
"GlobalTracer",
"(",
")",
",",
"otgrpc",
".",
"IncludingSpans",
"(",
"addTraceIfTracingEnabled",
")",
")",
"\n",
"}"
] |
// StreamServerInterceptor returns a GRPC interceptor for non-streaming GRPC RPCs
|
[
"StreamServerInterceptor",
"returns",
"a",
"GRPC",
"interceptor",
"for",
"non",
"-",
"streaming",
"GRPC",
"RPCs"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L179-L182
|
test
|
pachyderm/pachyderm
|
src/client/pkg/tracing/tracing.go
|
CloseAndReportTraces
|
func CloseAndReportTraces() {
if c, ok := opentracing.GlobalTracer().(io.Closer); ok {
c.Close()
}
}
|
go
|
func CloseAndReportTraces() {
if c, ok := opentracing.GlobalTracer().(io.Closer); ok {
c.Close()
}
}
|
[
"func",
"CloseAndReportTraces",
"(",
")",
"{",
"if",
"c",
",",
"ok",
":=",
"opentracing",
".",
"GlobalTracer",
"(",
")",
".",
"(",
"io",
".",
"Closer",
")",
";",
"ok",
"{",
"c",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
// CloseAndReportTraces tries to close the global tracer, which, in the case of
// the Jaeger tracer, causes it to send any unreported traces to the collector
|
[
"CloseAndReportTraces",
"tries",
"to",
"close",
"the",
"global",
"tracer",
"which",
"in",
"the",
"case",
"of",
"the",
"Jaeger",
"tracer",
"causes",
"it",
"to",
"send",
"any",
"unreported",
"traces",
"to",
"the",
"collector"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/tracing/tracing.go#L186-L190
|
test
|
pachyderm/pachyderm
|
src/server/pkg/storage/chunk/writer.go
|
newWriter
|
func newWriter(ctx context.Context, objC obj.Client, prefix string) *Writer {
// Initialize buzhash64 with WindowSize window.
hash := buzhash64.New()
hash.Write(make([]byte, WindowSize))
return &Writer{
ctx: ctx,
objC: objC,
prefix: prefix,
cbs: []func([]*DataRef) error{},
buf: &bytes.Buffer{},
hash: hash,
splitMask: (1 << uint64(AverageBits)) - 1,
}
}
|
go
|
func newWriter(ctx context.Context, objC obj.Client, prefix string) *Writer {
// Initialize buzhash64 with WindowSize window.
hash := buzhash64.New()
hash.Write(make([]byte, WindowSize))
return &Writer{
ctx: ctx,
objC: objC,
prefix: prefix,
cbs: []func([]*DataRef) error{},
buf: &bytes.Buffer{},
hash: hash,
splitMask: (1 << uint64(AverageBits)) - 1,
}
}
|
[
"func",
"newWriter",
"(",
"ctx",
"context",
".",
"Context",
",",
"objC",
"obj",
".",
"Client",
",",
"prefix",
"string",
")",
"*",
"Writer",
"{",
"hash",
":=",
"buzhash64",
".",
"New",
"(",
")",
"\n",
"hash",
".",
"Write",
"(",
"make",
"(",
"[",
"]",
"byte",
",",
"WindowSize",
")",
")",
"\n",
"return",
"&",
"Writer",
"{",
"ctx",
":",
"ctx",
",",
"objC",
":",
"objC",
",",
"prefix",
":",
"prefix",
",",
"cbs",
":",
"[",
"]",
"func",
"(",
"[",
"]",
"*",
"DataRef",
")",
"error",
"{",
"}",
",",
"buf",
":",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
",",
"hash",
":",
"hash",
",",
"splitMask",
":",
"(",
"1",
"<<",
"uint64",
"(",
"AverageBits",
")",
")",
"-",
"1",
",",
"}",
"\n",
"}"
] |
// newWriter creates a new Writer.
|
[
"newWriter",
"creates",
"a",
"new",
"Writer",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/storage/chunk/writer.go#L47-L60
|
test
|
pachyderm/pachyderm
|
src/server/pkg/backoff/backoff.go
|
For
|
func (b *ConstantBackOff) For(maxElapsed time.Duration) *ConstantBackOff {
b.MaxElapsedTime = maxElapsed
return b
}
|
go
|
func (b *ConstantBackOff) For(maxElapsed time.Duration) *ConstantBackOff {
b.MaxElapsedTime = maxElapsed
return b
}
|
[
"func",
"(",
"b",
"*",
"ConstantBackOff",
")",
"For",
"(",
"maxElapsed",
"time",
".",
"Duration",
")",
"*",
"ConstantBackOff",
"{",
"b",
".",
"MaxElapsedTime",
"=",
"maxElapsed",
"\n",
"return",
"b",
"\n",
"}"
] |
// For sets b.MaxElapsedTime to 'maxElapsed' and returns b
|
[
"For",
"sets",
"b",
".",
"MaxElapsedTime",
"to",
"maxElapsed",
"and",
"returns",
"b"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/backoff/backoff.go#L107-L110
|
test
|
pachyderm/pachyderm
|
src/server/pkg/log/log.go
|
Log
|
func (l *logger) Log(request interface{}, response interface{}, err error, duration time.Duration) {
if err != nil {
l.LogAtLevelFromDepth(request, response, err, duration, logrus.ErrorLevel, 4)
} else {
l.LogAtLevelFromDepth(request, response, err, duration, logrus.InfoLevel, 4)
}
// We have to grab the method's name here before we
// enter the goro's stack
go l.ReportMetric(getMethodName(), duration, err)
}
|
go
|
func (l *logger) Log(request interface{}, response interface{}, err error, duration time.Duration) {
if err != nil {
l.LogAtLevelFromDepth(request, response, err, duration, logrus.ErrorLevel, 4)
} else {
l.LogAtLevelFromDepth(request, response, err, duration, logrus.InfoLevel, 4)
}
// We have to grab the method's name here before we
// enter the goro's stack
go l.ReportMetric(getMethodName(), duration, err)
}
|
[
"func",
"(",
"l",
"*",
"logger",
")",
"Log",
"(",
"request",
"interface",
"{",
"}",
",",
"response",
"interface",
"{",
"}",
",",
"err",
"error",
",",
"duration",
"time",
".",
"Duration",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"l",
".",
"LogAtLevelFromDepth",
"(",
"request",
",",
"response",
",",
"err",
",",
"duration",
",",
"logrus",
".",
"ErrorLevel",
",",
"4",
")",
"\n",
"}",
"else",
"{",
"l",
".",
"LogAtLevelFromDepth",
"(",
"request",
",",
"response",
",",
"err",
",",
"duration",
",",
"logrus",
".",
"InfoLevel",
",",
"4",
")",
"\n",
"}",
"\n",
"go",
"l",
".",
"ReportMetric",
"(",
"getMethodName",
"(",
")",
",",
"duration",
",",
"err",
")",
"\n",
"}"
] |
// Helper function used to log requests and responses from our GRPC method
// implementations
|
[
"Helper",
"function",
"used",
"to",
"log",
"requests",
"and",
"responses",
"from",
"our",
"GRPC",
"method",
"implementations"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/log/log.go#L88-L97
|
test
|
pachyderm/pachyderm
|
src/server/pkg/log/log.go
|
Format
|
func (f FormatterFunc) Format(entry *logrus.Entry) ([]byte, error) {
return f(entry)
}
|
go
|
func (f FormatterFunc) Format(entry *logrus.Entry) ([]byte, error) {
return f(entry)
}
|
[
"func",
"(",
"f",
"FormatterFunc",
")",
"Format",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"f",
"(",
"entry",
")",
"\n",
"}"
] |
// Format proxies the closure in order to satisfy `logrus.Formatter`'s
// interface.
|
[
"Format",
"proxies",
"the",
"closure",
"in",
"order",
"to",
"satisfy",
"logrus",
".",
"Formatter",
"s",
"interface",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/log/log.go#L246-L248
|
test
|
pachyderm/pachyderm
|
src/server/pkg/log/log.go
|
NewGRPCLogWriter
|
func NewGRPCLogWriter(logger *logrus.Logger, source string) *GRPCLogWriter {
return &GRPCLogWriter{
logger: logger,
source: source,
}
}
|
go
|
func NewGRPCLogWriter(logger *logrus.Logger, source string) *GRPCLogWriter {
return &GRPCLogWriter{
logger: logger,
source: source,
}
}
|
[
"func",
"NewGRPCLogWriter",
"(",
"logger",
"*",
"logrus",
".",
"Logger",
",",
"source",
"string",
")",
"*",
"GRPCLogWriter",
"{",
"return",
"&",
"GRPCLogWriter",
"{",
"logger",
":",
"logger",
",",
"source",
":",
"source",
",",
"}",
"\n",
"}"
] |
// NewGRPCLogWriter creates a new GRPC log writer. `logger` specifies the
// underlying logger, and `source` specifies where these logs are coming from;
// it is added as a entry field for all log messages.
|
[
"NewGRPCLogWriter",
"creates",
"a",
"new",
"GRPC",
"log",
"writer",
".",
"logger",
"specifies",
"the",
"underlying",
"logger",
"and",
"source",
"specifies",
"where",
"these",
"logs",
"are",
"coming",
"from",
";",
"it",
"is",
"added",
"as",
"a",
"entry",
"field",
"for",
"all",
"log",
"messages",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/log/log.go#L296-L301
|
test
|
pachyderm/pachyderm
|
src/client/pkg/config/config.go
|
Read
|
func Read() (*Config, error) {
var c *Config
// Read json file
p := configPath()
if raw, err := ioutil.ReadFile(p); err == nil {
err = json.Unmarshal(raw, &c)
if err != nil {
return nil, err
}
} else if os.IsNotExist(err) {
// File doesn't exist, so create a new config
fmt.Println("no config detected at %q. Generating new config...", p)
c = &Config{}
} else {
return nil, fmt.Errorf("fatal: could not read config at %q: %v", p, err)
}
if c.UserID == "" {
fmt.Printf("No UserID present in config. Generating new UserID and "+
"updating config at %s\n", p)
uuid, err := uuid.NewV4()
if err != nil {
return nil, err
}
c.UserID = uuid.String()
if err := c.Write(); err != nil {
return nil, err
}
}
return c, nil
}
|
go
|
func Read() (*Config, error) {
var c *Config
// Read json file
p := configPath()
if raw, err := ioutil.ReadFile(p); err == nil {
err = json.Unmarshal(raw, &c)
if err != nil {
return nil, err
}
} else if os.IsNotExist(err) {
// File doesn't exist, so create a new config
fmt.Println("no config detected at %q. Generating new config...", p)
c = &Config{}
} else {
return nil, fmt.Errorf("fatal: could not read config at %q: %v", p, err)
}
if c.UserID == "" {
fmt.Printf("No UserID present in config. Generating new UserID and "+
"updating config at %s\n", p)
uuid, err := uuid.NewV4()
if err != nil {
return nil, err
}
c.UserID = uuid.String()
if err := c.Write(); err != nil {
return nil, err
}
}
return c, nil
}
|
[
"func",
"Read",
"(",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"var",
"c",
"*",
"Config",
"\n",
"p",
":=",
"configPath",
"(",
")",
"\n",
"if",
"raw",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"p",
")",
";",
"err",
"==",
"nil",
"{",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"raw",
",",
"&",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"else",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"no config detected at %q. Generating new config...\"",
",",
"p",
")",
"\n",
"c",
"=",
"&",
"Config",
"{",
"}",
"\n",
"}",
"else",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"fatal: could not read config at %q: %v\"",
",",
"p",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"UserID",
"==",
"\"\"",
"{",
"fmt",
".",
"Printf",
"(",
"\"No UserID present in config. Generating new UserID and \"",
"+",
"\"updating config at %s\\n\"",
",",
"\\n",
")",
"\n",
"p",
"\n",
"uuid",
",",
"err",
":=",
"uuid",
".",
"NewV4",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"c",
".",
"UserID",
"=",
"uuid",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Write",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}"
] |
// Read loads the Pachyderm config on this machine.
// If an existing configuration cannot be found, it sets up the defaults. Read
// returns a nil Config if and only if it returns a non-nil error.
|
[
"Read",
"loads",
"the",
"Pachyderm",
"config",
"on",
"this",
"machine",
".",
"If",
"an",
"existing",
"configuration",
"cannot",
"be",
"found",
"it",
"sets",
"up",
"the",
"defaults",
".",
"Read",
"returns",
"a",
"nil",
"Config",
"if",
"and",
"only",
"if",
"it",
"returns",
"a",
"non",
"-",
"nil",
"error",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/config/config.go#L28-L58
|
test
|
pachyderm/pachyderm
|
src/client/pkg/config/config.go
|
Write
|
func (c *Config) Write() error {
rawConfig, err := json.MarshalIndent(c, "", " ")
if err != nil {
return err
}
// If we're not using a custom config path, create the default config path
p := configPath()
if _, ok := os.LookupEnv(configEnvVar); ok {
// using overridden config path -- just make sure the parent dir exists
d := filepath.Dir(p)
if _, err := os.Stat(d); err != nil {
return fmt.Errorf("cannot use config at %s: could not stat parent directory (%v)", p, err)
}
} else {
// using the default config path, create the config directory
err = os.MkdirAll(defaultConfigDir, 0755)
if err != nil {
return err
}
}
return ioutil.WriteFile(p, rawConfig, 0644)
}
|
go
|
func (c *Config) Write() error {
rawConfig, err := json.MarshalIndent(c, "", " ")
if err != nil {
return err
}
// If we're not using a custom config path, create the default config path
p := configPath()
if _, ok := os.LookupEnv(configEnvVar); ok {
// using overridden config path -- just make sure the parent dir exists
d := filepath.Dir(p)
if _, err := os.Stat(d); err != nil {
return fmt.Errorf("cannot use config at %s: could not stat parent directory (%v)", p, err)
}
} else {
// using the default config path, create the config directory
err = os.MkdirAll(defaultConfigDir, 0755)
if err != nil {
return err
}
}
return ioutil.WriteFile(p, rawConfig, 0644)
}
|
[
"func",
"(",
"c",
"*",
"Config",
")",
"Write",
"(",
")",
"error",
"{",
"rawConfig",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"c",
",",
"\"\"",
",",
"\" \"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"p",
":=",
"configPath",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"os",
".",
"LookupEnv",
"(",
"configEnvVar",
")",
";",
"ok",
"{",
"d",
":=",
"filepath",
".",
"Dir",
"(",
"p",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"d",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"cannot use config at %s: could not stat parent directory (%v)\"",
",",
"p",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
"defaultConfigDir",
",",
"0755",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"ioutil",
".",
"WriteFile",
"(",
"p",
",",
"rawConfig",
",",
"0644",
")",
"\n",
"}"
] |
// Write writes the configuration in 'c' to this machine's Pachyderm config
// file.
|
[
"Write",
"writes",
"the",
"configuration",
"in",
"c",
"to",
"this",
"machine",
"s",
"Pachyderm",
"config",
"file",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/config/config.go#L62-L84
|
test
|
pachyderm/pachyderm
|
src/client/pkg/pbutil/pbutil.go
|
Read
|
func (r *readWriter) Read(val proto.Message) error {
buf, err := r.ReadBytes()
if err != nil {
return err
}
return proto.Unmarshal(buf, val)
}
|
go
|
func (r *readWriter) Read(val proto.Message) error {
buf, err := r.ReadBytes()
if err != nil {
return err
}
return proto.Unmarshal(buf, val)
}
|
[
"func",
"(",
"r",
"*",
"readWriter",
")",
"Read",
"(",
"val",
"proto",
".",
"Message",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"r",
".",
"ReadBytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"proto",
".",
"Unmarshal",
"(",
"buf",
",",
"val",
")",
"\n",
"}"
] |
// Read reads val from r.
|
[
"Read",
"reads",
"val",
"from",
"r",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/pbutil/pbutil.go#L54-L60
|
test
|
pachyderm/pachyderm
|
src/client/pkg/pbutil/pbutil.go
|
Write
|
func (r *readWriter) Write(val proto.Message) (int64, error) {
bytes, err := proto.Marshal(val)
if err != nil {
return 0, err
}
return r.WriteBytes(bytes)
}
|
go
|
func (r *readWriter) Write(val proto.Message) (int64, error) {
bytes, err := proto.Marshal(val)
if err != nil {
return 0, err
}
return r.WriteBytes(bytes)
}
|
[
"func",
"(",
"r",
"*",
"readWriter",
")",
"Write",
"(",
"val",
"proto",
".",
"Message",
")",
"(",
"int64",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"r",
".",
"WriteBytes",
"(",
"bytes",
")",
"\n",
"}"
] |
// Write writes val to r.
|
[
"Write",
"writes",
"val",
"to",
"r",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/pbutil/pbutil.go#L72-L78
|
test
|
pachyderm/pachyderm
|
src/client/pkg/pbutil/pbutil.go
|
NewReadWriter
|
func NewReadWriter(rw io.ReadWriter) ReadWriter {
return &readWriter{r: rw, w: rw}
}
|
go
|
func NewReadWriter(rw io.ReadWriter) ReadWriter {
return &readWriter{r: rw, w: rw}
}
|
[
"func",
"NewReadWriter",
"(",
"rw",
"io",
".",
"ReadWriter",
")",
"ReadWriter",
"{",
"return",
"&",
"readWriter",
"{",
"r",
":",
"rw",
",",
"w",
":",
"rw",
"}",
"\n",
"}"
] |
// NewReadWriter returns a new ReadWriter with rw as both its source and its sink.
|
[
"NewReadWriter",
"returns",
"a",
"new",
"ReadWriter",
"with",
"rw",
"as",
"both",
"its",
"source",
"and",
"its",
"sink",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/pbutil/pbutil.go#L91-L93
|
test
|
pachyderm/pachyderm
|
src/server/pps/server/githook/githook.go
|
RunGitHookServer
|
func RunGitHookServer(address string, etcdAddress string, etcdPrefix string) error {
c, err := client.NewFromAddress(address)
if err != nil {
return err
}
etcdClient, err := etcd.New(etcd.Config{
Endpoints: []string{etcdAddress},
DialOptions: client.DefaultDialOptions(),
})
if err != nil {
return err
}
hook, err := github.New()
if err != nil {
return err
}
s := &gitHookServer{
hook,
c,
etcdClient,
ppsdb.Pipelines(etcdClient, etcdPrefix),
}
return http.ListenAndServe(fmt.Sprintf(":%d", GitHookPort), s)
}
|
go
|
func RunGitHookServer(address string, etcdAddress string, etcdPrefix string) error {
c, err := client.NewFromAddress(address)
if err != nil {
return err
}
etcdClient, err := etcd.New(etcd.Config{
Endpoints: []string{etcdAddress},
DialOptions: client.DefaultDialOptions(),
})
if err != nil {
return err
}
hook, err := github.New()
if err != nil {
return err
}
s := &gitHookServer{
hook,
c,
etcdClient,
ppsdb.Pipelines(etcdClient, etcdPrefix),
}
return http.ListenAndServe(fmt.Sprintf(":%d", GitHookPort), s)
}
|
[
"func",
"RunGitHookServer",
"(",
"address",
"string",
",",
"etcdAddress",
"string",
",",
"etcdPrefix",
"string",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"NewFromAddress",
"(",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"etcdClient",
",",
"err",
":=",
"etcd",
".",
"New",
"(",
"etcd",
".",
"Config",
"{",
"Endpoints",
":",
"[",
"]",
"string",
"{",
"etcdAddress",
"}",
",",
"DialOptions",
":",
"client",
".",
"DefaultDialOptions",
"(",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"hook",
",",
"err",
":=",
"github",
".",
"New",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
":=",
"&",
"gitHookServer",
"{",
"hook",
",",
"c",
",",
"etcdClient",
",",
"ppsdb",
".",
"Pipelines",
"(",
"etcdClient",
",",
"etcdPrefix",
")",
",",
"}",
"\n",
"return",
"http",
".",
"ListenAndServe",
"(",
"fmt",
".",
"Sprintf",
"(",
"\":%d\"",
",",
"GitHookPort",
")",
",",
"s",
")",
"\n",
"}"
] |
// RunGitHookServer starts the webhook server
|
[
"RunGitHookServer",
"starts",
"the",
"webhook",
"server"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/githook/githook.go#L59-L82
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cert/logging_conn.go
|
newLoggingPipe
|
func newLoggingPipe() *loggingPipe {
p := &loggingPipe{}
p.clientReader, p.clientWriter = io.Pipe()
p.clientReader = io.TeeReader(p.clientReader, &p.ServerToClientBuf)
p.serverReader, p.serverWriter = io.Pipe()
p.serverReader = io.TeeReader(p.serverReader, &p.ClientToServerBuf)
return p
}
|
go
|
func newLoggingPipe() *loggingPipe {
p := &loggingPipe{}
p.clientReader, p.clientWriter = io.Pipe()
p.clientReader = io.TeeReader(p.clientReader, &p.ServerToClientBuf)
p.serverReader, p.serverWriter = io.Pipe()
p.serverReader = io.TeeReader(p.serverReader, &p.ClientToServerBuf)
return p
}
|
[
"func",
"newLoggingPipe",
"(",
")",
"*",
"loggingPipe",
"{",
"p",
":=",
"&",
"loggingPipe",
"{",
"}",
"\n",
"p",
".",
"clientReader",
",",
"p",
".",
"clientWriter",
"=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"p",
".",
"clientReader",
"=",
"io",
".",
"TeeReader",
"(",
"p",
".",
"clientReader",
",",
"&",
"p",
".",
"ServerToClientBuf",
")",
"\n",
"p",
".",
"serverReader",
",",
"p",
".",
"serverWriter",
"=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"p",
".",
"serverReader",
"=",
"io",
".",
"TeeReader",
"(",
"p",
".",
"serverReader",
",",
"&",
"p",
".",
"ClientToServerBuf",
")",
"\n",
"return",
"p",
"\n",
"}"
] |
// newLoggingPipe initializes a loggingPipe
|
[
"newLoggingPipe",
"initializes",
"a",
"loggingPipe"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/logging_conn.go#L40-L47
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cert/logging_conn.go
|
Read
|
func (l *loggingConn) Read(b []byte) (n int, err error) {
return l.r.Read(b)
}
|
go
|
func (l *loggingConn) Read(b []byte) (n int, err error) {
return l.r.Read(b)
}
|
[
"func",
"(",
"l",
"*",
"loggingConn",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"l",
".",
"r",
".",
"Read",
"(",
"b",
")",
"\n",
"}"
] |
// Read implements the corresponding method of net.Conn
|
[
"Read",
"implements",
"the",
"corresponding",
"method",
"of",
"net",
".",
"Conn"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/logging_conn.go#L89-L91
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cert/logging_conn.go
|
Write
|
func (l *loggingConn) Write(b []byte) (n int, err error) {
return l.w.Write(b)
}
|
go
|
func (l *loggingConn) Write(b []byte) (n int, err error) {
return l.w.Write(b)
}
|
[
"func",
"(",
"l",
"*",
"loggingConn",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"l",
".",
"w",
".",
"Write",
"(",
"b",
")",
"\n",
"}"
] |
// Write implements the corresponding method of net.Conn
|
[
"Write",
"implements",
"the",
"corresponding",
"method",
"of",
"net",
".",
"Conn"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/logging_conn.go#L94-L96
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cert/logging_conn.go
|
Accept
|
func (l *TestListener) Accept() (net.Conn, error) {
conn := <-l.connCh
if conn == nil {
return nil, errors.New("Accept() has already been called on this TestListener")
}
return conn, nil
}
|
go
|
func (l *TestListener) Accept() (net.Conn, error) {
conn := <-l.connCh
if conn == nil {
return nil, errors.New("Accept() has already been called on this TestListener")
}
return conn, nil
}
|
[
"func",
"(",
"l",
"*",
"TestListener",
")",
"Accept",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conn",
":=",
"<-",
"l",
".",
"connCh",
"\n",
"if",
"conn",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"Accept() has already been called on this TestListener\"",
")",
"\n",
"}",
"\n",
"return",
"conn",
",",
"nil",
"\n",
"}"
] |
// Accept implements the corresponding method of net.Listener for
// TestListener
|
[
"Accept",
"implements",
"the",
"corresponding",
"method",
"of",
"net",
".",
"Listener",
"for",
"TestListener"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/logging_conn.go#L182-L188
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cert/logging_conn.go
|
Close
|
func (l *TestListener) Close() error {
l.connMu.Lock()
defer l.connMu.Unlock()
c := <-l.connCh
if c != nil {
close(l.connCh)
}
return nil
}
|
go
|
func (l *TestListener) Close() error {
l.connMu.Lock()
defer l.connMu.Unlock()
c := <-l.connCh
if c != nil {
close(l.connCh)
}
return nil
}
|
[
"func",
"(",
"l",
"*",
"TestListener",
")",
"Close",
"(",
")",
"error",
"{",
"l",
".",
"connMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"connMu",
".",
"Unlock",
"(",
")",
"\n",
"c",
":=",
"<-",
"l",
".",
"connCh",
"\n",
"if",
"c",
"!=",
"nil",
"{",
"close",
"(",
"l",
".",
"connCh",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Close implements the corresponding method of net.Listener for
// TestListener. Any blocked Accept operations will be unblocked and return
// errors.
|
[
"Close",
"implements",
"the",
"corresponding",
"method",
"of",
"net",
".",
"Listener",
"for",
"TestListener",
".",
"Any",
"blocked",
"Accept",
"operations",
"will",
"be",
"unblocked",
"and",
"return",
"errors",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/logging_conn.go#L193-L201
|
test
|
pachyderm/pachyderm
|
src/server/pkg/hashtree/error.go
|
errorf
|
func errorf(c ErrCode, fmtStr string, args ...interface{}) error {
return &hashTreeError{
code: c,
s: fmt.Sprintf(fmtStr, args...),
}
}
|
go
|
func errorf(c ErrCode, fmtStr string, args ...interface{}) error {
return &hashTreeError{
code: c,
s: fmt.Sprintf(fmtStr, args...),
}
}
|
[
"func",
"errorf",
"(",
"c",
"ErrCode",
",",
"fmtStr",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"&",
"hashTreeError",
"{",
"code",
":",
"c",
",",
"s",
":",
"fmt",
".",
"Sprintf",
"(",
"fmtStr",
",",
"args",
"...",
")",
",",
"}",
"\n",
"}"
] |
// errorf is analogous to fmt.Errorf, but generates hashTreeErrors instead of
// errorStrings.
|
[
"errorf",
"is",
"analogous",
"to",
"fmt",
".",
"Errorf",
"but",
"generates",
"hashTreeErrors",
"instead",
"of",
"errorStrings",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/error.go#L32-L37
|
test
|
pachyderm/pachyderm
|
src/server/pkg/serviceenv/service_env.go
|
InitWithKube
|
func InitWithKube(config *Configuration) *ServiceEnv {
env := InitServiceEnv(config)
env.kubeEg.Go(env.initKubeClient)
return env // env is not ready yet
}
|
go
|
func InitWithKube(config *Configuration) *ServiceEnv {
env := InitServiceEnv(config)
env.kubeEg.Go(env.initKubeClient)
return env // env is not ready yet
}
|
[
"func",
"InitWithKube",
"(",
"config",
"*",
"Configuration",
")",
"*",
"ServiceEnv",
"{",
"env",
":=",
"InitServiceEnv",
"(",
"config",
")",
"\n",
"env",
".",
"kubeEg",
".",
"Go",
"(",
"env",
".",
"initKubeClient",
")",
"\n",
"return",
"env",
"\n",
"}"
] |
// InitWithKube is like InitServiceEnv, but also assumes that it's run inside
// a kubernetes cluster and tries to connect to the kubernetes API server.
|
[
"InitWithKube",
"is",
"like",
"InitServiceEnv",
"but",
"also",
"assumes",
"that",
"it",
"s",
"run",
"inside",
"a",
"kubernetes",
"cluster",
"and",
"tries",
"to",
"connect",
"to",
"the",
"kubernetes",
"API",
"server",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/serviceenv/service_env.go#L85-L89
|
test
|
pachyderm/pachyderm
|
src/server/pkg/serviceenv/service_env.go
|
GetEtcdClient
|
func (env *ServiceEnv) GetEtcdClient() *etcd.Client {
if err := env.etcdEg.Wait(); err != nil {
panic(err) // If env can't connect, there's no sensible way to recover
}
if env.etcdClient == nil {
panic("service env never connected to etcd")
}
return env.etcdClient
}
|
go
|
func (env *ServiceEnv) GetEtcdClient() *etcd.Client {
if err := env.etcdEg.Wait(); err != nil {
panic(err) // If env can't connect, there's no sensible way to recover
}
if env.etcdClient == nil {
panic("service env never connected to etcd")
}
return env.etcdClient
}
|
[
"func",
"(",
"env",
"*",
"ServiceEnv",
")",
"GetEtcdClient",
"(",
")",
"*",
"etcd",
".",
"Client",
"{",
"if",
"err",
":=",
"env",
".",
"etcdEg",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"env",
".",
"etcdClient",
"==",
"nil",
"{",
"panic",
"(",
"\"service env never connected to etcd\"",
")",
"\n",
"}",
"\n",
"return",
"env",
".",
"etcdClient",
"\n",
"}"
] |
// GetEtcdClient returns the already connected etcd client without modification.
|
[
"GetEtcdClient",
"returns",
"the",
"already",
"connected",
"etcd",
"client",
"without",
"modification",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/serviceenv/service_env.go#L174-L182
|
test
|
pachyderm/pachyderm
|
src/server/pkg/serviceenv/service_env.go
|
GetKubeClient
|
func (env *ServiceEnv) GetKubeClient() *kube.Clientset {
if err := env.kubeEg.Wait(); err != nil {
panic(err) // If env can't connect, there's no sensible way to recover
}
if env.kubeClient == nil {
panic("service env never connected to kubernetes")
}
return env.kubeClient
}
|
go
|
func (env *ServiceEnv) GetKubeClient() *kube.Clientset {
if err := env.kubeEg.Wait(); err != nil {
panic(err) // If env can't connect, there's no sensible way to recover
}
if env.kubeClient == nil {
panic("service env never connected to kubernetes")
}
return env.kubeClient
}
|
[
"func",
"(",
"env",
"*",
"ServiceEnv",
")",
"GetKubeClient",
"(",
")",
"*",
"kube",
".",
"Clientset",
"{",
"if",
"err",
":=",
"env",
".",
"kubeEg",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"env",
".",
"kubeClient",
"==",
"nil",
"{",
"panic",
"(",
"\"service env never connected to kubernetes\"",
")",
"\n",
"}",
"\n",
"return",
"env",
".",
"kubeClient",
"\n",
"}"
] |
// GetKubeClient returns the already connected Kubernetes API client without
// modification.
|
[
"GetKubeClient",
"returns",
"the",
"already",
"connected",
"Kubernetes",
"API",
"client",
"without",
"modification",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/serviceenv/service_env.go#L186-L194
|
test
|
pachyderm/pachyderm
|
src/server/pps/hash.go
|
NewHasher
|
func NewHasher(jobModulus uint64, pipelineModulus uint64) *Hasher {
return &Hasher{
JobModulus: jobModulus,
PipelineModulus: pipelineModulus,
}
}
|
go
|
func NewHasher(jobModulus uint64, pipelineModulus uint64) *Hasher {
return &Hasher{
JobModulus: jobModulus,
PipelineModulus: pipelineModulus,
}
}
|
[
"func",
"NewHasher",
"(",
"jobModulus",
"uint64",
",",
"pipelineModulus",
"uint64",
")",
"*",
"Hasher",
"{",
"return",
"&",
"Hasher",
"{",
"JobModulus",
":",
"jobModulus",
",",
"PipelineModulus",
":",
"pipelineModulus",
",",
"}",
"\n",
"}"
] |
// NewHasher creates a hasher.
|
[
"NewHasher",
"creates",
"a",
"hasher",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/hash.go#L14-L19
|
test
|
pachyderm/pachyderm
|
src/server/pps/hash.go
|
HashJob
|
func (s *Hasher) HashJob(jobID string) uint64 {
return uint64(adler32.Checksum([]byte(jobID))) % s.JobModulus
}
|
go
|
func (s *Hasher) HashJob(jobID string) uint64 {
return uint64(adler32.Checksum([]byte(jobID))) % s.JobModulus
}
|
[
"func",
"(",
"s",
"*",
"Hasher",
")",
"HashJob",
"(",
"jobID",
"string",
")",
"uint64",
"{",
"return",
"uint64",
"(",
"adler32",
".",
"Checksum",
"(",
"[",
"]",
"byte",
"(",
"jobID",
")",
")",
")",
"%",
"s",
".",
"JobModulus",
"\n",
"}"
] |
// HashJob computes and returns the hash of a job.
|
[
"HashJob",
"computes",
"and",
"returns",
"the",
"hash",
"of",
"a",
"job",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/hash.go#L22-L24
|
test
|
pachyderm/pachyderm
|
src/server/pps/hash.go
|
HashPipeline
|
func (s *Hasher) HashPipeline(pipelineName string) uint64 {
return uint64(adler32.Checksum([]byte(pipelineName))) % s.PipelineModulus
}
|
go
|
func (s *Hasher) HashPipeline(pipelineName string) uint64 {
return uint64(adler32.Checksum([]byte(pipelineName))) % s.PipelineModulus
}
|
[
"func",
"(",
"s",
"*",
"Hasher",
")",
"HashPipeline",
"(",
"pipelineName",
"string",
")",
"uint64",
"{",
"return",
"uint64",
"(",
"adler32",
".",
"Checksum",
"(",
"[",
"]",
"byte",
"(",
"pipelineName",
")",
")",
")",
"%",
"s",
".",
"PipelineModulus",
"\n",
"}"
] |
// HashPipeline computes and returns the hash of a pipeline.
|
[
"HashPipeline",
"computes",
"and",
"returns",
"the",
"hash",
"of",
"a",
"pipeline",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/hash.go#L27-L29
|
test
|
pachyderm/pachyderm
|
src/server/worker/client.go
|
Status
|
func Status(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) ([]*pps.WorkerStatus, error) {
workerClients, err := Clients(ctx, pipelineRcName, etcdClient, etcdPrefix, workerGrpcPort)
if err != nil {
return nil, err
}
var result []*pps.WorkerStatus
for _, workerClient := range workerClients {
status, err := workerClient.Status(ctx, &types.Empty{})
if err != nil {
return nil, err
}
result = append(result, status)
}
return result, nil
}
|
go
|
func Status(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) ([]*pps.WorkerStatus, error) {
workerClients, err := Clients(ctx, pipelineRcName, etcdClient, etcdPrefix, workerGrpcPort)
if err != nil {
return nil, err
}
var result []*pps.WorkerStatus
for _, workerClient := range workerClients {
status, err := workerClient.Status(ctx, &types.Empty{})
if err != nil {
return nil, err
}
result = append(result, status)
}
return result, nil
}
|
[
"func",
"Status",
"(",
"ctx",
"context",
".",
"Context",
",",
"pipelineRcName",
"string",
",",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"etcdPrefix",
"string",
",",
"workerGrpcPort",
"uint16",
")",
"(",
"[",
"]",
"*",
"pps",
".",
"WorkerStatus",
",",
"error",
")",
"{",
"workerClients",
",",
"err",
":=",
"Clients",
"(",
"ctx",
",",
"pipelineRcName",
",",
"etcdClient",
",",
"etcdPrefix",
",",
"workerGrpcPort",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"result",
"[",
"]",
"*",
"pps",
".",
"WorkerStatus",
"\n",
"for",
"_",
",",
"workerClient",
":=",
"range",
"workerClients",
"{",
"status",
",",
"err",
":=",
"workerClient",
".",
"Status",
"(",
"ctx",
",",
"&",
"types",
".",
"Empty",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"status",
")",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] |
// Status returns the statuses of workers referenced by pipelineRcName.
// pipelineRcName is the name of the pipeline's RC and can be gotten with
// ppsutil.PipelineRcName. You can also pass "" for pipelineRcName to get all
// clients for all workers.
|
[
"Status",
"returns",
"the",
"statuses",
"of",
"workers",
"referenced",
"by",
"pipelineRcName",
".",
"pipelineRcName",
"is",
"the",
"name",
"of",
"the",
"pipeline",
"s",
"RC",
"and",
"can",
"be",
"gotten",
"with",
"ppsutil",
".",
"PipelineRcName",
".",
"You",
"can",
"also",
"pass",
"for",
"pipelineRcName",
"to",
"get",
"all",
"clients",
"for",
"all",
"workers",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/client.go#L28-L42
|
test
|
pachyderm/pachyderm
|
src/server/worker/client.go
|
Cancel
|
func Cancel(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client,
etcdPrefix string, workerGrpcPort uint16, jobID string, dataFilter []string) error {
workerClients, err := Clients(ctx, pipelineRcName, etcdClient, etcdPrefix, workerGrpcPort)
if err != nil {
return err
}
success := false
for _, workerClient := range workerClients {
resp, err := workerClient.Cancel(ctx, &CancelRequest{
JobID: jobID,
DataFilters: dataFilter,
})
if err != nil {
return err
}
if resp.Success {
success = true
}
}
if !success {
return fmt.Errorf("datum matching filter %+v could not be found for jobID %s", dataFilter, jobID)
}
return nil
}
|
go
|
func Cancel(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client,
etcdPrefix string, workerGrpcPort uint16, jobID string, dataFilter []string) error {
workerClients, err := Clients(ctx, pipelineRcName, etcdClient, etcdPrefix, workerGrpcPort)
if err != nil {
return err
}
success := false
for _, workerClient := range workerClients {
resp, err := workerClient.Cancel(ctx, &CancelRequest{
JobID: jobID,
DataFilters: dataFilter,
})
if err != nil {
return err
}
if resp.Success {
success = true
}
}
if !success {
return fmt.Errorf("datum matching filter %+v could not be found for jobID %s", dataFilter, jobID)
}
return nil
}
|
[
"func",
"Cancel",
"(",
"ctx",
"context",
".",
"Context",
",",
"pipelineRcName",
"string",
",",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"etcdPrefix",
"string",
",",
"workerGrpcPort",
"uint16",
",",
"jobID",
"string",
",",
"dataFilter",
"[",
"]",
"string",
")",
"error",
"{",
"workerClients",
",",
"err",
":=",
"Clients",
"(",
"ctx",
",",
"pipelineRcName",
",",
"etcdClient",
",",
"etcdPrefix",
",",
"workerGrpcPort",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"success",
":=",
"false",
"\n",
"for",
"_",
",",
"workerClient",
":=",
"range",
"workerClients",
"{",
"resp",
",",
"err",
":=",
"workerClient",
".",
"Cancel",
"(",
"ctx",
",",
"&",
"CancelRequest",
"{",
"JobID",
":",
"jobID",
",",
"DataFilters",
":",
"dataFilter",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"resp",
".",
"Success",
"{",
"success",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"success",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"datum matching filter %+v could not be found for jobID %s\"",
",",
"dataFilter",
",",
"jobID",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Cancel cancels a set of datums running on workers.
// pipelineRcName is the name of the pipeline's RC and can be gotten with
// ppsutil.PipelineRcName.
|
[
"Cancel",
"cancels",
"a",
"set",
"of",
"datums",
"running",
"on",
"workers",
".",
"pipelineRcName",
"is",
"the",
"name",
"of",
"the",
"pipeline",
"s",
"RC",
"and",
"can",
"be",
"gotten",
"with",
"ppsutil",
".",
"PipelineRcName",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/client.go#L47-L70
|
test
|
pachyderm/pachyderm
|
src/server/worker/client.go
|
Conns
|
func Conns(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) ([]*grpc.ClientConn, error) {
resp, err := etcdClient.Get(ctx, path.Join(etcdPrefix, WorkerEtcdPrefix, pipelineRcName), etcd.WithPrefix())
if err != nil {
return nil, err
}
var result []*grpc.ClientConn
for _, kv := range resp.Kvs {
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", path.Base(string(kv.Key)), workerGrpcPort),
append(client.DefaultDialOptions(), grpc.WithInsecure())...)
if err != nil {
return nil, err
}
result = append(result, conn)
}
return result, nil
}
|
go
|
func Conns(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) ([]*grpc.ClientConn, error) {
resp, err := etcdClient.Get(ctx, path.Join(etcdPrefix, WorkerEtcdPrefix, pipelineRcName), etcd.WithPrefix())
if err != nil {
return nil, err
}
var result []*grpc.ClientConn
for _, kv := range resp.Kvs {
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", path.Base(string(kv.Key)), workerGrpcPort),
append(client.DefaultDialOptions(), grpc.WithInsecure())...)
if err != nil {
return nil, err
}
result = append(result, conn)
}
return result, nil
}
|
[
"func",
"Conns",
"(",
"ctx",
"context",
".",
"Context",
",",
"pipelineRcName",
"string",
",",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"etcdPrefix",
"string",
",",
"workerGrpcPort",
"uint16",
")",
"(",
"[",
"]",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"etcdClient",
".",
"Get",
"(",
"ctx",
",",
"path",
".",
"Join",
"(",
"etcdPrefix",
",",
"WorkerEtcdPrefix",
",",
"pipelineRcName",
")",
",",
"etcd",
".",
"WithPrefix",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"result",
"[",
"]",
"*",
"grpc",
".",
"ClientConn",
"\n",
"for",
"_",
",",
"kv",
":=",
"range",
"resp",
".",
"Kvs",
"{",
"conn",
",",
"err",
":=",
"grpc",
".",
"Dial",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"%s:%d\"",
",",
"path",
".",
"Base",
"(",
"string",
"(",
"kv",
".",
"Key",
")",
")",
",",
"workerGrpcPort",
")",
",",
"append",
"(",
"client",
".",
"DefaultDialOptions",
"(",
")",
",",
"grpc",
".",
"WithInsecure",
"(",
")",
")",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"conn",
")",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] |
// Conns returns a slice of connections to worker servers.
// pipelineRcName is the name of the pipeline's RC and can be gotten with
// ppsutil.PipelineRcName. You can also pass "" for pipelineRcName to get all
// clients for all workers.
|
[
"Conns",
"returns",
"a",
"slice",
"of",
"connections",
"to",
"worker",
"servers",
".",
"pipelineRcName",
"is",
"the",
"name",
"of",
"the",
"pipeline",
"s",
"RC",
"and",
"can",
"be",
"gotten",
"with",
"ppsutil",
".",
"PipelineRcName",
".",
"You",
"can",
"also",
"pass",
"for",
"pipelineRcName",
"to",
"get",
"all",
"clients",
"for",
"all",
"workers",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/client.go#L76-L91
|
test
|
pachyderm/pachyderm
|
src/server/worker/client.go
|
Clients
|
func Clients(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) ([]Client, error) {
conns, err := Conns(ctx, pipelineRcName, etcdClient, etcdPrefix, workerGrpcPort)
if err != nil {
return nil, err
}
var result []Client
for _, conn := range conns {
result = append(result, newClient(conn))
}
return result, nil
}
|
go
|
func Clients(ctx context.Context, pipelineRcName string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) ([]Client, error) {
conns, err := Conns(ctx, pipelineRcName, etcdClient, etcdPrefix, workerGrpcPort)
if err != nil {
return nil, err
}
var result []Client
for _, conn := range conns {
result = append(result, newClient(conn))
}
return result, nil
}
|
[
"func",
"Clients",
"(",
"ctx",
"context",
".",
"Context",
",",
"pipelineRcName",
"string",
",",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"etcdPrefix",
"string",
",",
"workerGrpcPort",
"uint16",
")",
"(",
"[",
"]",
"Client",
",",
"error",
")",
"{",
"conns",
",",
"err",
":=",
"Conns",
"(",
"ctx",
",",
"pipelineRcName",
",",
"etcdClient",
",",
"etcdPrefix",
",",
"workerGrpcPort",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"result",
"[",
"]",
"Client",
"\n",
"for",
"_",
",",
"conn",
":=",
"range",
"conns",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"newClient",
"(",
"conn",
")",
")",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] |
// Clients returns a slice of worker clients for a pipeline.
// pipelineRcName is the name of the pipeline's RC and can be gotten with
// ppsutil.PipelineRcName. You can also pass "" for pipelineRcName to get all
// clients for all workers.
|
[
"Clients",
"returns",
"a",
"slice",
"of",
"worker",
"clients",
"for",
"a",
"pipeline",
".",
"pipelineRcName",
"is",
"the",
"name",
"of",
"the",
"pipeline",
"s",
"RC",
"and",
"can",
"be",
"gotten",
"with",
"ppsutil",
".",
"PipelineRcName",
".",
"You",
"can",
"also",
"pass",
"for",
"pipelineRcName",
"to",
"get",
"all",
"clients",
"for",
"all",
"workers",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/client.go#L110-L120
|
test
|
pachyderm/pachyderm
|
src/server/worker/client.go
|
NewClient
|
func NewClient(address string) (Client, error) {
port, err := strconv.Atoi(os.Getenv(client.PPSWorkerPortEnv))
if err != nil {
return Client{}, err
}
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", address, port),
append(client.DefaultDialOptions(), grpc.WithInsecure())...)
if err != nil {
return Client{}, err
}
return newClient(conn), nil
}
|
go
|
func NewClient(address string) (Client, error) {
port, err := strconv.Atoi(os.Getenv(client.PPSWorkerPortEnv))
if err != nil {
return Client{}, err
}
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", address, port),
append(client.DefaultDialOptions(), grpc.WithInsecure())...)
if err != nil {
return Client{}, err
}
return newClient(conn), nil
}
|
[
"func",
"NewClient",
"(",
"address",
"string",
")",
"(",
"Client",
",",
"error",
")",
"{",
"port",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"os",
".",
"Getenv",
"(",
"client",
".",
"PPSWorkerPortEnv",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Client",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"conn",
",",
"err",
":=",
"grpc",
".",
"Dial",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"%s:%d\"",
",",
"address",
",",
"port",
")",
",",
"append",
"(",
"client",
".",
"DefaultDialOptions",
"(",
")",
",",
"grpc",
".",
"WithInsecure",
"(",
")",
")",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Client",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"newClient",
"(",
"conn",
")",
",",
"nil",
"\n",
"}"
] |
// NewClient returns a worker client for the worker at the IP address passed in.
|
[
"NewClient",
"returns",
"a",
"worker",
"client",
"for",
"the",
"worker",
"at",
"the",
"IP",
"address",
"passed",
"in",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/client.go#L123-L134
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
RunFixedArgs
|
func RunFixedArgs(numArgs int, run func([]string) error) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
if len(args) != numArgs {
fmt.Printf("expected %d arguments, got %d\n\n", numArgs, len(args))
cmd.Usage()
} else {
if err := run(args); err != nil {
ErrorAndExit("%v", err)
}
}
}
}
|
go
|
func RunFixedArgs(numArgs int, run func([]string) error) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
if len(args) != numArgs {
fmt.Printf("expected %d arguments, got %d\n\n", numArgs, len(args))
cmd.Usage()
} else {
if err := run(args); err != nil {
ErrorAndExit("%v", err)
}
}
}
}
|
[
"func",
"RunFixedArgs",
"(",
"numArgs",
"int",
",",
"run",
"func",
"(",
"[",
"]",
"string",
")",
"error",
")",
"func",
"(",
"*",
"cobra",
".",
"Command",
",",
"[",
"]",
"string",
")",
"{",
"return",
"func",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"numArgs",
"{",
"fmt",
".",
"Printf",
"(",
"\"expected %d arguments, got %d\\n\\n\"",
",",
"\\n",
",",
"\\n",
")",
"\n",
"numArgs",
"\n",
"}",
"else",
"len",
"(",
"args",
")",
"\n",
"}",
"\n",
"}"
] |
// RunFixedArgs wraps a function in a function
// that checks its exact argument count.
|
[
"RunFixedArgs",
"wraps",
"a",
"function",
"in",
"a",
"function",
"that",
"checks",
"its",
"exact",
"argument",
"count",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L16-L27
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
RunBoundedArgs
|
func RunBoundedArgs(min int, max int, run func([]string) error) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
if len(args) < min || len(args) > max {
fmt.Printf("expected %d to %d arguments, got %d\n\n", min, max, len(args))
cmd.Usage()
} else {
if err := run(args); err != nil {
ErrorAndExit("%v", err)
}
}
}
}
|
go
|
func RunBoundedArgs(min int, max int, run func([]string) error) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
if len(args) < min || len(args) > max {
fmt.Printf("expected %d to %d arguments, got %d\n\n", min, max, len(args))
cmd.Usage()
} else {
if err := run(args); err != nil {
ErrorAndExit("%v", err)
}
}
}
}
|
[
"func",
"RunBoundedArgs",
"(",
"min",
"int",
",",
"max",
"int",
",",
"run",
"func",
"(",
"[",
"]",
"string",
")",
"error",
")",
"func",
"(",
"*",
"cobra",
".",
"Command",
",",
"[",
"]",
"string",
")",
"{",
"return",
"func",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"<",
"min",
"||",
"len",
"(",
"args",
")",
">",
"max",
"{",
"fmt",
".",
"Printf",
"(",
"\"expected %d to %d arguments, got %d\\n\\n\"",
",",
"\\n",
",",
"\\n",
",",
"min",
")",
"\n",
"max",
"\n",
"}",
"else",
"len",
"(",
"args",
")",
"\n",
"}",
"\n",
"}"
] |
// RunBoundedArgs wraps a function in a function
// that checks its argument count is within a range.
|
[
"RunBoundedArgs",
"wraps",
"a",
"function",
"in",
"a",
"function",
"that",
"checks",
"its",
"argument",
"count",
"is",
"within",
"a",
"range",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L31-L42
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
Run
|
func Run(run func(args []string) error) func(*cobra.Command, []string) {
return func(_ *cobra.Command, args []string) {
if err := run(args); err != nil {
ErrorAndExit(err.Error())
}
}
}
|
go
|
func Run(run func(args []string) error) func(*cobra.Command, []string) {
return func(_ *cobra.Command, args []string) {
if err := run(args); err != nil {
ErrorAndExit(err.Error())
}
}
}
|
[
"func",
"Run",
"(",
"run",
"func",
"(",
"args",
"[",
"]",
"string",
")",
"error",
")",
"func",
"(",
"*",
"cobra",
".",
"Command",
",",
"[",
"]",
"string",
")",
"{",
"return",
"func",
"(",
"_",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"err",
":=",
"run",
"(",
"args",
")",
";",
"err",
"!=",
"nil",
"{",
"ErrorAndExit",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// Run makes a new cobra run function that wraps the given function.
|
[
"Run",
"makes",
"a",
"new",
"cobra",
"run",
"function",
"that",
"wraps",
"the",
"given",
"function",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L45-L51
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
ErrorAndExit
|
func ErrorAndExit(format string, args ...interface{}) {
if errString := strings.TrimSpace(fmt.Sprintf(format, args...)); errString != "" {
fmt.Fprintf(os.Stderr, "%s\n", errString)
}
os.Exit(1)
}
|
go
|
func ErrorAndExit(format string, args ...interface{}) {
if errString := strings.TrimSpace(fmt.Sprintf(format, args...)); errString != "" {
fmt.Fprintf(os.Stderr, "%s\n", errString)
}
os.Exit(1)
}
|
[
"func",
"ErrorAndExit",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"errString",
":=",
"strings",
".",
"TrimSpace",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
";",
"errString",
"!=",
"\"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"%s\\n\"",
",",
"\\n",
")",
"\n",
"}",
"\n",
"errString",
"\n",
"}"
] |
// ErrorAndExit errors with the given format and args, and then exits.
|
[
"ErrorAndExit",
"errors",
"with",
"the",
"given",
"format",
"and",
"args",
"and",
"then",
"exits",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L54-L59
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
ParseCommit
|
func ParseCommit(arg string) (*pfs.Commit, error) {
parts := strings.SplitN(arg, "@", 2)
if parts[0] == "" {
return nil, fmt.Errorf("invalid format \"%s\": repo cannot be empty", arg)
}
commit := &pfs.Commit{
Repo: &pfs.Repo{
Name: parts[0],
},
ID: "",
}
if len(parts) == 2 {
commit.ID = parts[1]
}
return commit, nil
}
|
go
|
func ParseCommit(arg string) (*pfs.Commit, error) {
parts := strings.SplitN(arg, "@", 2)
if parts[0] == "" {
return nil, fmt.Errorf("invalid format \"%s\": repo cannot be empty", arg)
}
commit := &pfs.Commit{
Repo: &pfs.Repo{
Name: parts[0],
},
ID: "",
}
if len(parts) == 2 {
commit.ID = parts[1]
}
return commit, nil
}
|
[
"func",
"ParseCommit",
"(",
"arg",
"string",
")",
"(",
"*",
"pfs",
".",
"Commit",
",",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"arg",
",",
"\"@\"",
",",
"2",
")",
"\n",
"if",
"parts",
"[",
"0",
"]",
"==",
"\"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"invalid format \\\"%s\\\": repo cannot be empty\"",
",",
"\\\"",
")",
"\n",
"}",
"\n",
"\\\"",
"\n",
"arg",
"\n",
"commit",
":=",
"&",
"pfs",
".",
"Commit",
"{",
"Repo",
":",
"&",
"pfs",
".",
"Repo",
"{",
"Name",
":",
"parts",
"[",
"0",
"]",
",",
"}",
",",
"ID",
":",
"\"\"",
",",
"}",
"\n",
"}"
] |
// ParseCommit takes an argument of the form "repo[@branch-or-commit]" and
// returns the corresponding *pfs.Commit.
|
[
"ParseCommit",
"takes",
"an",
"argument",
"of",
"the",
"form",
"repo",
"["
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L63-L78
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
ParseBranch
|
func ParseBranch(arg string) (*pfs.Branch, error) {
commit, err := ParseCommit(arg)
if err != nil {
return nil, err
}
return &pfs.Branch{Repo: commit.Repo, Name: commit.ID}, nil
}
|
go
|
func ParseBranch(arg string) (*pfs.Branch, error) {
commit, err := ParseCommit(arg)
if err != nil {
return nil, err
}
return &pfs.Branch{Repo: commit.Repo, Name: commit.ID}, nil
}
|
[
"func",
"ParseBranch",
"(",
"arg",
"string",
")",
"(",
"*",
"pfs",
".",
"Branch",
",",
"error",
")",
"{",
"commit",
",",
"err",
":=",
"ParseCommit",
"(",
"arg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"pfs",
".",
"Branch",
"{",
"Repo",
":",
"commit",
".",
"Repo",
",",
"Name",
":",
"commit",
".",
"ID",
"}",
",",
"nil",
"\n",
"}"
] |
// ParseBranch takes an argument of the form "repo[@branch]" and
// returns the corresponding *pfs.Branch. This uses ParseCommit under the hood
// because a branch name is usually interchangeable with a commit-id.
|
[
"ParseBranch",
"takes",
"an",
"argument",
"of",
"the",
"form",
"repo",
"["
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L97-L103
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
ParseFile
|
func ParseFile(arg string) (*pfs.File, error) {
repoAndRest := strings.SplitN(arg, "@", 2)
if repoAndRest[0] == "" {
return nil, fmt.Errorf("invalid format \"%s\": repo cannot be empty", arg)
}
file := &pfs.File{
Commit: &pfs.Commit{
Repo: &pfs.Repo{
Name: repoAndRest[0],
},
ID: "",
},
Path: "",
}
if len(repoAndRest) > 1 {
commitAndPath := strings.SplitN(repoAndRest[1], ":", 2)
if commitAndPath[0] == "" {
return nil, fmt.Errorf("invalid format \"%s\": commit cannot be empty", arg)
}
file.Commit.ID = commitAndPath[0]
if len(commitAndPath) > 1 {
file.Path = commitAndPath[1]
}
}
return file, nil
}
|
go
|
func ParseFile(arg string) (*pfs.File, error) {
repoAndRest := strings.SplitN(arg, "@", 2)
if repoAndRest[0] == "" {
return nil, fmt.Errorf("invalid format \"%s\": repo cannot be empty", arg)
}
file := &pfs.File{
Commit: &pfs.Commit{
Repo: &pfs.Repo{
Name: repoAndRest[0],
},
ID: "",
},
Path: "",
}
if len(repoAndRest) > 1 {
commitAndPath := strings.SplitN(repoAndRest[1], ":", 2)
if commitAndPath[0] == "" {
return nil, fmt.Errorf("invalid format \"%s\": commit cannot be empty", arg)
}
file.Commit.ID = commitAndPath[0]
if len(commitAndPath) > 1 {
file.Path = commitAndPath[1]
}
}
return file, nil
}
|
[
"func",
"ParseFile",
"(",
"arg",
"string",
")",
"(",
"*",
"pfs",
".",
"File",
",",
"error",
")",
"{",
"repoAndRest",
":=",
"strings",
".",
"SplitN",
"(",
"arg",
",",
"\"@\"",
",",
"2",
")",
"\n",
"if",
"repoAndRest",
"[",
"0",
"]",
"==",
"\"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"invalid format \\\"%s\\\": repo cannot be empty\"",
",",
"\\\"",
")",
"\n",
"}",
"\n",
"\\\"",
"\n",
"arg",
"\n",
"file",
":=",
"&",
"pfs",
".",
"File",
"{",
"Commit",
":",
"&",
"pfs",
".",
"Commit",
"{",
"Repo",
":",
"&",
"pfs",
".",
"Repo",
"{",
"Name",
":",
"repoAndRest",
"[",
"0",
"]",
",",
"}",
",",
"ID",
":",
"\"\"",
",",
"}",
",",
"Path",
":",
"\"\"",
",",
"}",
"\n",
"}"
] |
// ParseFile takes an argument of the form "repo[@branch-or-commit[:path]]", and
// returns the corresponding *pfs.File.
|
[
"ParseFile",
"takes",
"an",
"argument",
"of",
"the",
"form",
"repo",
"["
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L121-L146
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
Set
|
func (r *RepeatedStringArg) Set(s string) error {
*r = append(*r, s)
return nil
}
|
go
|
func (r *RepeatedStringArg) Set(s string) error {
*r = append(*r, s)
return nil
}
|
[
"func",
"(",
"r",
"*",
"RepeatedStringArg",
")",
"Set",
"(",
"s",
"string",
")",
"error",
"{",
"*",
"r",
"=",
"append",
"(",
"*",
"r",
",",
"s",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Set adds a string to r
|
[
"Set",
"adds",
"a",
"string",
"to",
"r"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L177-L180
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cmdutil/cobra.go
|
SetDocsUsage
|
func SetDocsUsage(command *cobra.Command) {
command.SetHelpTemplate(`{{or .Long .Short}}
{{.UsageString}}
`)
command.SetUsageFunc(func(cmd *cobra.Command) error {
rootCmd := cmd.Root()
// Walk the command tree, finding commands with the documented word
var associated []*cobra.Command
var walk func(*cobra.Command)
walk = func(cursor *cobra.Command) {
if cursor.Name() == cmd.Name() && cursor.CommandPath() != cmd.CommandPath() {
associated = append(associated, cursor)
}
for _, subcmd := range cursor.Commands() {
walk(subcmd)
}
}
walk(rootCmd)
var maxCommandPath int
for _, x := range associated {
commandPathLen := len(x.CommandPath())
if commandPathLen > maxCommandPath {
maxCommandPath = commandPathLen
}
}
templateFuncs := template.FuncMap{
"pad": func(s string) string {
format := fmt.Sprintf("%%-%ds", maxCommandPath+1)
return fmt.Sprintf(format, s)
},
"associated": func() []*cobra.Command {
return associated
},
}
text := `Associated Commands:{{range associated}}{{if .IsAvailableCommand}}
{{pad .CommandPath}} {{.Short}}{{end}}{{end}}`
t := template.New("top")
t.Funcs(templateFuncs)
template.Must(t.Parse(text))
return t.Execute(cmd.Out(), cmd)
})
}
|
go
|
func SetDocsUsage(command *cobra.Command) {
command.SetHelpTemplate(`{{or .Long .Short}}
{{.UsageString}}
`)
command.SetUsageFunc(func(cmd *cobra.Command) error {
rootCmd := cmd.Root()
// Walk the command tree, finding commands with the documented word
var associated []*cobra.Command
var walk func(*cobra.Command)
walk = func(cursor *cobra.Command) {
if cursor.Name() == cmd.Name() && cursor.CommandPath() != cmd.CommandPath() {
associated = append(associated, cursor)
}
for _, subcmd := range cursor.Commands() {
walk(subcmd)
}
}
walk(rootCmd)
var maxCommandPath int
for _, x := range associated {
commandPathLen := len(x.CommandPath())
if commandPathLen > maxCommandPath {
maxCommandPath = commandPathLen
}
}
templateFuncs := template.FuncMap{
"pad": func(s string) string {
format := fmt.Sprintf("%%-%ds", maxCommandPath+1)
return fmt.Sprintf(format, s)
},
"associated": func() []*cobra.Command {
return associated
},
}
text := `Associated Commands:{{range associated}}{{if .IsAvailableCommand}}
{{pad .CommandPath}} {{.Short}}{{end}}{{end}}`
t := template.New("top")
t.Funcs(templateFuncs)
template.Must(t.Parse(text))
return t.Execute(cmd.Out(), cmd)
})
}
|
[
"func",
"SetDocsUsage",
"(",
"command",
"*",
"cobra",
".",
"Command",
")",
"{",
"command",
".",
"SetHelpTemplate",
"(",
"`{{or .Long .Short}}{{.UsageString}}`",
")",
"\n",
"command",
".",
"SetUsageFunc",
"(",
"func",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
")",
"error",
"{",
"rootCmd",
":=",
"cmd",
".",
"Root",
"(",
")",
"\n",
"var",
"associated",
"[",
"]",
"*",
"cobra",
".",
"Command",
"\n",
"var",
"walk",
"func",
"(",
"*",
"cobra",
".",
"Command",
")",
"\n",
"walk",
"=",
"func",
"(",
"cursor",
"*",
"cobra",
".",
"Command",
")",
"{",
"if",
"cursor",
".",
"Name",
"(",
")",
"==",
"cmd",
".",
"Name",
"(",
")",
"&&",
"cursor",
".",
"CommandPath",
"(",
")",
"!=",
"cmd",
".",
"CommandPath",
"(",
")",
"{",
"associated",
"=",
"append",
"(",
"associated",
",",
"cursor",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"subcmd",
":=",
"range",
"cursor",
".",
"Commands",
"(",
")",
"{",
"walk",
"(",
"subcmd",
")",
"\n",
"}",
"\n",
"}",
"\n",
"walk",
"(",
"rootCmd",
")",
"\n",
"var",
"maxCommandPath",
"int",
"\n",
"for",
"_",
",",
"x",
":=",
"range",
"associated",
"{",
"commandPathLen",
":=",
"len",
"(",
"x",
".",
"CommandPath",
"(",
")",
")",
"\n",
"if",
"commandPathLen",
">",
"maxCommandPath",
"{",
"maxCommandPath",
"=",
"commandPathLen",
"\n",
"}",
"\n",
"}",
"\n",
"templateFuncs",
":=",
"template",
".",
"FuncMap",
"{",
"\"pad\"",
":",
"func",
"(",
"s",
"string",
")",
"string",
"{",
"format",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"%%-%ds\"",
",",
"maxCommandPath",
"+",
"1",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"s",
")",
"\n",
"}",
",",
"\"associated\"",
":",
"func",
"(",
")",
"[",
"]",
"*",
"cobra",
".",
"Command",
"{",
"return",
"associated",
"\n",
"}",
",",
"}",
"\n",
"text",
":=",
"`Associated Commands:{{range associated}}{{if .IsAvailableCommand}} {{pad .CommandPath}} {{.Short}}{{end}}{{end}}`",
"\n",
"t",
":=",
"template",
".",
"New",
"(",
"\"top\"",
")",
"\n",
"t",
".",
"Funcs",
"(",
"templateFuncs",
")",
"\n",
"template",
".",
"Must",
"(",
"t",
".",
"Parse",
"(",
"text",
")",
")",
"\n",
"return",
"t",
".",
"Execute",
"(",
"cmd",
".",
"Out",
"(",
")",
",",
"cmd",
")",
"\n",
"}",
")",
"\n",
"}"
] |
// SetDocsUsage sets the usage string for a docs-style command. Docs commands
// have no functionality except to output some docs and related commands, and
// should not specify a 'Run' attribute.
|
[
"SetDocsUsage",
"sets",
"the",
"usage",
"string",
"for",
"a",
"docs",
"-",
"style",
"command",
".",
"Docs",
"commands",
"have",
"no",
"functionality",
"except",
"to",
"output",
"some",
"docs",
"and",
"related",
"commands",
"and",
"should",
"not",
"specify",
"a",
"Run",
"attribute",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L275-L323
|
test
|
pachyderm/pachyderm
|
src/server/pps/server/master.go
|
makeCronCommits
|
func (a *apiServer) makeCronCommits(pachClient *client.APIClient, in *pps.Input) error {
schedule, err := cron.ParseStandard(in.Cron.Spec)
if err != nil {
return err // Shouldn't happen, as the input is validated in CreatePipeline
}
// make sure there isn't an unfinished commit on the branch
commitInfo, err := pachClient.InspectCommit(in.Cron.Repo, "master")
if err != nil && !isNilBranchErr(err) {
return err
} else if commitInfo != nil && commitInfo.Finished == nil {
// and if there is, delete it
if err = pachClient.DeleteCommit(in.Cron.Repo, "master"); err != nil {
return err
}
}
var latestTime time.Time
files, err := pachClient.ListFile(in.Cron.Repo, "master", "")
if err != nil && !isNilBranchErr(err) {
return err
} else if err != nil || len(files) == 0 {
// File not found, this happens the first time the pipeline is run
latestTime, err = types.TimestampFromProto(in.Cron.Start)
if err != nil {
return err
}
} else {
// Take the name of the most recent file as the latest timestamp
// ListFile returns the files in lexicographical order, and the RFC3339 format goes
// from largest unit of time to smallest, so the most recent file will be the last one
latestTime, err = time.Parse(time.RFC3339, path.Base(files[len(files)-1].File.Path))
if err != nil {
return err
}
}
for {
// get the time of the next time from the latest time using the cron schedule
next := schedule.Next(latestTime)
// and wait until then to make the next commit
time.Sleep(time.Until(next))
if err != nil {
return err
}
// We need the DeleteFile and the PutFile to happen in the same commit
_, err = pachClient.StartCommit(in.Cron.Repo, "master")
if err != nil {
return err
}
if in.Cron.Overwrite {
// If we want to "overwrite" the file, we need to delete the file with the previous time
err := pachClient.DeleteFile(in.Cron.Repo, "master", latestTime.Format(time.RFC3339))
if err != nil && !isNotFoundErr(err) && !isNilBranchErr(err) {
return fmt.Errorf("delete error %v", err)
}
}
// Put in an empty file named by the timestamp
_, err = pachClient.PutFile(in.Cron.Repo, "master", next.Format(time.RFC3339), strings.NewReader(""))
if err != nil {
return fmt.Errorf("put error %v", err)
}
err = pachClient.FinishCommit(in.Cron.Repo, "master")
if err != nil {
return err
}
// set latestTime to the next time
latestTime = next
}
}
|
go
|
func (a *apiServer) makeCronCommits(pachClient *client.APIClient, in *pps.Input) error {
schedule, err := cron.ParseStandard(in.Cron.Spec)
if err != nil {
return err // Shouldn't happen, as the input is validated in CreatePipeline
}
// make sure there isn't an unfinished commit on the branch
commitInfo, err := pachClient.InspectCommit(in.Cron.Repo, "master")
if err != nil && !isNilBranchErr(err) {
return err
} else if commitInfo != nil && commitInfo.Finished == nil {
// and if there is, delete it
if err = pachClient.DeleteCommit(in.Cron.Repo, "master"); err != nil {
return err
}
}
var latestTime time.Time
files, err := pachClient.ListFile(in.Cron.Repo, "master", "")
if err != nil && !isNilBranchErr(err) {
return err
} else if err != nil || len(files) == 0 {
// File not found, this happens the first time the pipeline is run
latestTime, err = types.TimestampFromProto(in.Cron.Start)
if err != nil {
return err
}
} else {
// Take the name of the most recent file as the latest timestamp
// ListFile returns the files in lexicographical order, and the RFC3339 format goes
// from largest unit of time to smallest, so the most recent file will be the last one
latestTime, err = time.Parse(time.RFC3339, path.Base(files[len(files)-1].File.Path))
if err != nil {
return err
}
}
for {
// get the time of the next time from the latest time using the cron schedule
next := schedule.Next(latestTime)
// and wait until then to make the next commit
time.Sleep(time.Until(next))
if err != nil {
return err
}
// We need the DeleteFile and the PutFile to happen in the same commit
_, err = pachClient.StartCommit(in.Cron.Repo, "master")
if err != nil {
return err
}
if in.Cron.Overwrite {
// If we want to "overwrite" the file, we need to delete the file with the previous time
err := pachClient.DeleteFile(in.Cron.Repo, "master", latestTime.Format(time.RFC3339))
if err != nil && !isNotFoundErr(err) && !isNilBranchErr(err) {
return fmt.Errorf("delete error %v", err)
}
}
// Put in an empty file named by the timestamp
_, err = pachClient.PutFile(in.Cron.Repo, "master", next.Format(time.RFC3339), strings.NewReader(""))
if err != nil {
return fmt.Errorf("put error %v", err)
}
err = pachClient.FinishCommit(in.Cron.Repo, "master")
if err != nil {
return err
}
// set latestTime to the next time
latestTime = next
}
}
|
[
"func",
"(",
"a",
"*",
"apiServer",
")",
"makeCronCommits",
"(",
"pachClient",
"*",
"client",
".",
"APIClient",
",",
"in",
"*",
"pps",
".",
"Input",
")",
"error",
"{",
"schedule",
",",
"err",
":=",
"cron",
".",
"ParseStandard",
"(",
"in",
".",
"Cron",
".",
"Spec",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"commitInfo",
",",
"err",
":=",
"pachClient",
".",
"InspectCommit",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"isNilBranchErr",
"(",
"err",
")",
"{",
"return",
"err",
"\n",
"}",
"else",
"if",
"commitInfo",
"!=",
"nil",
"&&",
"commitInfo",
".",
"Finished",
"==",
"nil",
"{",
"if",
"err",
"=",
"pachClient",
".",
"DeleteCommit",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"var",
"latestTime",
"time",
".",
"Time",
"\n",
"files",
",",
"err",
":=",
"pachClient",
".",
"ListFile",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
",",
"\"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"isNilBranchErr",
"(",
"err",
")",
"{",
"return",
"err",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"||",
"len",
"(",
"files",
")",
"==",
"0",
"{",
"latestTime",
",",
"err",
"=",
"types",
".",
"TimestampFromProto",
"(",
"in",
".",
"Cron",
".",
"Start",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"latestTime",
",",
"err",
"=",
"time",
".",
"Parse",
"(",
"time",
".",
"RFC3339",
",",
"path",
".",
"Base",
"(",
"files",
"[",
"len",
"(",
"files",
")",
"-",
"1",
"]",
".",
"File",
".",
"Path",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"{",
"next",
":=",
"schedule",
".",
"Next",
"(",
"latestTime",
")",
"\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Until",
"(",
"next",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"pachClient",
".",
"StartCommit",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"in",
".",
"Cron",
".",
"Overwrite",
"{",
"err",
":=",
"pachClient",
".",
"DeleteFile",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
",",
"latestTime",
".",
"Format",
"(",
"time",
".",
"RFC3339",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"isNotFoundErr",
"(",
"err",
")",
"&&",
"!",
"isNilBranchErr",
"(",
"err",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"delete error %v\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"pachClient",
".",
"PutFile",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
",",
"next",
".",
"Format",
"(",
"time",
".",
"RFC3339",
")",
",",
"strings",
".",
"NewReader",
"(",
"\"\"",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"put error %v\"",
",",
"err",
")",
"\n",
"}",
"\n",
"err",
"=",
"pachClient",
".",
"FinishCommit",
"(",
"in",
".",
"Cron",
".",
"Repo",
",",
"\"master\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"latestTime",
"=",
"next",
"\n",
"}",
"\n",
"}"
] |
// makeCronCommits makes commits to a single cron input's repo. It's
// a helper function called by monitorPipeline.
|
[
"makeCronCommits",
"makes",
"commits",
"to",
"a",
"single",
"cron",
"input",
"s",
"repo",
".",
"It",
"s",
"a",
"helper",
"function",
"called",
"by",
"monitorPipeline",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/master.go#L561-L633
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/tracing.go
|
Writer
|
func (o *tracingObjClient) Writer(ctx context.Context, name string) (io.WriteCloser, error) {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Writer", "name", name)
if span != nil {
defer span.Finish()
}
return o.Client.Writer(ctx, name)
}
|
go
|
func (o *tracingObjClient) Writer(ctx context.Context, name string) (io.WriteCloser, error) {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Writer", "name", name)
if span != nil {
defer span.Finish()
}
return o.Client.Writer(ctx, name)
}
|
[
"func",
"(",
"o",
"*",
"tracingObjClient",
")",
"Writer",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"AddSpanToAnyExisting",
"(",
"ctx",
",",
"o",
".",
"provider",
"+",
"\".Writer\"",
",",
"\"name\"",
",",
"name",
")",
"\n",
"if",
"span",
"!=",
"nil",
"{",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n",
"}",
"\n",
"return",
"o",
".",
"Client",
".",
"Writer",
"(",
"ctx",
",",
"name",
")",
"\n",
"}"
] |
// Writer implements the corresponding method in the Client interface
|
[
"Writer",
"implements",
"the",
"corresponding",
"method",
"in",
"the",
"Client",
"interface"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/tracing.go#L23-L29
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/tracing.go
|
Reader
|
func (o *tracingObjClient) Reader(ctx context.Context, name string, offset uint64, size uint64) (io.ReadCloser, error) {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Reader",
"name", name,
"offset", fmt.Sprintf("%d", offset),
"size", fmt.Sprintf("%d", size))
defer tracing.FinishAnySpan(span)
return o.Client.Reader(ctx, name, offset, size)
}
|
go
|
func (o *tracingObjClient) Reader(ctx context.Context, name string, offset uint64, size uint64) (io.ReadCloser, error) {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Reader",
"name", name,
"offset", fmt.Sprintf("%d", offset),
"size", fmt.Sprintf("%d", size))
defer tracing.FinishAnySpan(span)
return o.Client.Reader(ctx, name, offset, size)
}
|
[
"func",
"(",
"o",
"*",
"tracingObjClient",
")",
"Reader",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"offset",
"uint64",
",",
"size",
"uint64",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"AddSpanToAnyExisting",
"(",
"ctx",
",",
"o",
".",
"provider",
"+",
"\".Reader\"",
",",
"\"name\"",
",",
"name",
",",
"\"offset\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"%d\"",
",",
"offset",
")",
",",
"\"size\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"%d\"",
",",
"size",
")",
")",
"\n",
"defer",
"tracing",
".",
"FinishAnySpan",
"(",
"span",
")",
"\n",
"return",
"o",
".",
"Client",
".",
"Reader",
"(",
"ctx",
",",
"name",
",",
"offset",
",",
"size",
")",
"\n",
"}"
] |
// Reader implements the corresponding method in the Client interface
|
[
"Reader",
"implements",
"the",
"corresponding",
"method",
"in",
"the",
"Client",
"interface"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/tracing.go#L32-L39
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/tracing.go
|
Delete
|
func (o *tracingObjClient) Delete(ctx context.Context, name string) error {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Delete",
"name", name)
defer tracing.FinishAnySpan(span)
return o.Client.Delete(ctx, name)
}
|
go
|
func (o *tracingObjClient) Delete(ctx context.Context, name string) error {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Delete",
"name", name)
defer tracing.FinishAnySpan(span)
return o.Client.Delete(ctx, name)
}
|
[
"func",
"(",
"o",
"*",
"tracingObjClient",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"AddSpanToAnyExisting",
"(",
"ctx",
",",
"o",
".",
"provider",
"+",
"\".Delete\"",
",",
"\"name\"",
",",
"name",
")",
"\n",
"defer",
"tracing",
".",
"FinishAnySpan",
"(",
"span",
")",
"\n",
"return",
"o",
".",
"Client",
".",
"Delete",
"(",
"ctx",
",",
"name",
")",
"\n",
"}"
] |
// Delete implements the corresponding method in the Client interface
|
[
"Delete",
"implements",
"the",
"corresponding",
"method",
"in",
"the",
"Client",
"interface"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/tracing.go#L42-L47
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/tracing.go
|
Walk
|
func (o *tracingObjClient) Walk(ctx context.Context, prefix string, fn func(name string) error) error {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Walk",
"prefix", prefix)
defer tracing.FinishAnySpan(span)
return o.Client.Walk(ctx, prefix, fn)
}
|
go
|
func (o *tracingObjClient) Walk(ctx context.Context, prefix string, fn func(name string) error) error {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Walk",
"prefix", prefix)
defer tracing.FinishAnySpan(span)
return o.Client.Walk(ctx, prefix, fn)
}
|
[
"func",
"(",
"o",
"*",
"tracingObjClient",
")",
"Walk",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
",",
"fn",
"func",
"(",
"name",
"string",
")",
"error",
")",
"error",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"AddSpanToAnyExisting",
"(",
"ctx",
",",
"o",
".",
"provider",
"+",
"\".Walk\"",
",",
"\"prefix\"",
",",
"prefix",
")",
"\n",
"defer",
"tracing",
".",
"FinishAnySpan",
"(",
"span",
")",
"\n",
"return",
"o",
".",
"Client",
".",
"Walk",
"(",
"ctx",
",",
"prefix",
",",
"fn",
")",
"\n",
"}"
] |
// Walk implements the corresponding method in the Client interface
|
[
"Walk",
"implements",
"the",
"corresponding",
"method",
"in",
"the",
"Client",
"interface"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/tracing.go#L50-L55
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/tracing.go
|
Exists
|
func (o *tracingObjClient) Exists(ctx context.Context, name string) bool {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Exists",
"name", name)
defer tracing.FinishAnySpan(span)
return o.Client.Exists(ctx, name)
}
|
go
|
func (o *tracingObjClient) Exists(ctx context.Context, name string) bool {
span, ctx := tracing.AddSpanToAnyExisting(ctx, o.provider+".Exists",
"name", name)
defer tracing.FinishAnySpan(span)
return o.Client.Exists(ctx, name)
}
|
[
"func",
"(",
"o",
"*",
"tracingObjClient",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"AddSpanToAnyExisting",
"(",
"ctx",
",",
"o",
".",
"provider",
"+",
"\".Exists\"",
",",
"\"name\"",
",",
"name",
")",
"\n",
"defer",
"tracing",
".",
"FinishAnySpan",
"(",
"span",
")",
"\n",
"return",
"o",
".",
"Client",
".",
"Exists",
"(",
"ctx",
",",
"name",
")",
"\n",
"}"
] |
// Exists implements the corresponding method in the Client interface
|
[
"Exists",
"implements",
"the",
"corresponding",
"method",
"in",
"the",
"Client",
"interface"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/tracing.go#L58-L63
|
test
|
pachyderm/pachyderm
|
src/client/pfs/pfs.go
|
GetBlock
|
func GetBlock(hash hash.Hash) *Block {
return &Block{
Hash: base64.URLEncoding.EncodeToString(hash.Sum(nil)),
}
}
|
go
|
func GetBlock(hash hash.Hash) *Block {
return &Block{
Hash: base64.URLEncoding.EncodeToString(hash.Sum(nil)),
}
}
|
[
"func",
"GetBlock",
"(",
"hash",
"hash",
".",
"Hash",
")",
"*",
"Block",
"{",
"return",
"&",
"Block",
"{",
"Hash",
":",
"base64",
".",
"URLEncoding",
".",
"EncodeToString",
"(",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
",",
"}",
"\n",
"}"
] |
// GetBlock encodes a hash into a readable format in the form of a Block.
|
[
"GetBlock",
"encodes",
"a",
"hash",
"into",
"a",
"readable",
"format",
"in",
"the",
"form",
"of",
"a",
"Block",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs/pfs.go#L37-L41
|
test
|
pachyderm/pachyderm
|
src/server/health/health.go
|
Health
|
func (h *healthServer) Health(context.Context, *types.Empty) (*types.Empty, error) {
if !h.ready {
return nil, fmt.Errorf("server not ready")
}
return &types.Empty{}, nil
}
|
go
|
func (h *healthServer) Health(context.Context, *types.Empty) (*types.Empty, error) {
if !h.ready {
return nil, fmt.Errorf("server not ready")
}
return &types.Empty{}, nil
}
|
[
"func",
"(",
"h",
"*",
"healthServer",
")",
"Health",
"(",
"context",
".",
"Context",
",",
"*",
"types",
".",
"Empty",
")",
"(",
"*",
"types",
".",
"Empty",
",",
"error",
")",
"{",
"if",
"!",
"h",
".",
"ready",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"server not ready\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"types",
".",
"Empty",
"{",
"}",
",",
"nil",
"\n",
"}"
] |
// Health implements the Health method for healthServer.
|
[
"Health",
"implements",
"the",
"Health",
"method",
"for",
"healthServer",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/health/health.go#L27-L32
|
test
|
pachyderm/pachyderm
|
src/server/pkg/hashtree/path.go
|
split
|
func split(p string) (string, string) {
return clean(path.Dir(p)), base(p)
}
|
go
|
func split(p string) (string, string) {
return clean(path.Dir(p)), base(p)
}
|
[
"func",
"split",
"(",
"p",
"string",
")",
"(",
"string",
",",
"string",
")",
"{",
"return",
"clean",
"(",
"path",
".",
"Dir",
"(",
"p",
")",
")",
",",
"base",
"(",
"p",
")",
"\n",
"}"
] |
// split is like path.Split, but uses this library's defaults for canonical
// paths
|
[
"split",
"is",
"like",
"path",
".",
"Split",
"but",
"uses",
"this",
"library",
"s",
"defaults",
"for",
"canonical",
"paths"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/path.go#L63-L65
|
test
|
pachyderm/pachyderm
|
src/server/pkg/hashtree/path.go
|
ValidatePath
|
func ValidatePath(path string) error {
path = clean(path)
match, _ := regexp.MatchString("^[ -~]+$", path)
if !match {
return fmt.Errorf("path (%v) invalid: only printable ASCII characters allowed", path)
}
if IsGlob(path) {
return fmt.Errorf("path (%v) invalid: globbing character (%v) not allowed in path", path, globRegex.FindString(path))
}
return nil
}
|
go
|
func ValidatePath(path string) error {
path = clean(path)
match, _ := regexp.MatchString("^[ -~]+$", path)
if !match {
return fmt.Errorf("path (%v) invalid: only printable ASCII characters allowed", path)
}
if IsGlob(path) {
return fmt.Errorf("path (%v) invalid: globbing character (%v) not allowed in path", path, globRegex.FindString(path))
}
return nil
}
|
[
"func",
"ValidatePath",
"(",
"path",
"string",
")",
"error",
"{",
"path",
"=",
"clean",
"(",
"path",
")",
"\n",
"match",
",",
"_",
":=",
"regexp",
".",
"MatchString",
"(",
"\"^[ -~]+$\"",
",",
"path",
")",
"\n",
"if",
"!",
"match",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"path (%v) invalid: only printable ASCII characters allowed\"",
",",
"path",
")",
"\n",
"}",
"\n",
"if",
"IsGlob",
"(",
"path",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"path (%v) invalid: globbing character (%v) not allowed in path\"",
",",
"path",
",",
"globRegex",
".",
"FindString",
"(",
"path",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// ValidatePath checks if a file path is legal
|
[
"ValidatePath",
"checks",
"if",
"a",
"file",
"path",
"is",
"legal"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/path.go#L74-L87
|
test
|
pachyderm/pachyderm
|
src/server/worker/worker.go
|
MatchDatum
|
func MatchDatum(filter []string, data []*pps.InputFile) bool {
// All paths in request.DataFilters must appear somewhere in the log
// line's inputs, or it's filtered
matchesData := true
dataFilters:
for _, dataFilter := range filter {
for _, datum := range data {
if dataFilter == datum.Path ||
dataFilter == base64.StdEncoding.EncodeToString(datum.Hash) ||
dataFilter == hex.EncodeToString(datum.Hash) {
continue dataFilters // Found, move to next filter
}
}
matchesData = false
break
}
return matchesData
}
|
go
|
func MatchDatum(filter []string, data []*pps.InputFile) bool {
// All paths in request.DataFilters must appear somewhere in the log
// line's inputs, or it's filtered
matchesData := true
dataFilters:
for _, dataFilter := range filter {
for _, datum := range data {
if dataFilter == datum.Path ||
dataFilter == base64.StdEncoding.EncodeToString(datum.Hash) ||
dataFilter == hex.EncodeToString(datum.Hash) {
continue dataFilters // Found, move to next filter
}
}
matchesData = false
break
}
return matchesData
}
|
[
"func",
"MatchDatum",
"(",
"filter",
"[",
"]",
"string",
",",
"data",
"[",
"]",
"*",
"pps",
".",
"InputFile",
")",
"bool",
"{",
"matchesData",
":=",
"true",
"\n",
"dataFilters",
":",
"for",
"_",
",",
"dataFilter",
":=",
"range",
"filter",
"{",
"for",
"_",
",",
"datum",
":=",
"range",
"data",
"{",
"if",
"dataFilter",
"==",
"datum",
".",
"Path",
"||",
"dataFilter",
"==",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"datum",
".",
"Hash",
")",
"||",
"dataFilter",
"==",
"hex",
".",
"EncodeToString",
"(",
"datum",
".",
"Hash",
")",
"{",
"continue",
"dataFilters",
"\n",
"}",
"\n",
"}",
"\n",
"matchesData",
"=",
"false",
"\n",
"break",
"\n",
"}",
"\n",
"return",
"matchesData",
"\n",
"}"
] |
// MatchDatum checks if a datum matches a filter. To match each string in
// filter must correspond match at least 1 datum's Path or Hash. Order of
// filter and data is irrelevant.
|
[
"MatchDatum",
"checks",
"if",
"a",
"datum",
"matches",
"a",
"filter",
".",
"To",
"match",
"each",
"string",
"in",
"filter",
"must",
"correspond",
"match",
"at",
"least",
"1",
"datum",
"s",
"Path",
"or",
"Hash",
".",
"Order",
"of",
"filter",
"and",
"data",
"is",
"irrelevant",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/worker.go#L12-L29
|
test
|
pachyderm/pachyderm
|
src/server/pkg/cache/server/server.go
|
NewCacheServer
|
func NewCacheServer(router shard.Router, shards uint64) CacheServer {
server := &groupCacheServer{
Logger: log.NewLogger("CacheServer"),
router: router,
localShards: make(map[uint64]bool),
shards: shards,
}
groupcache.RegisterPeerPicker(func() groupcache.PeerPicker { return server })
return server
}
|
go
|
func NewCacheServer(router shard.Router, shards uint64) CacheServer {
server := &groupCacheServer{
Logger: log.NewLogger("CacheServer"),
router: router,
localShards: make(map[uint64]bool),
shards: shards,
}
groupcache.RegisterPeerPicker(func() groupcache.PeerPicker { return server })
return server
}
|
[
"func",
"NewCacheServer",
"(",
"router",
"shard",
".",
"Router",
",",
"shards",
"uint64",
")",
"CacheServer",
"{",
"server",
":=",
"&",
"groupCacheServer",
"{",
"Logger",
":",
"log",
".",
"NewLogger",
"(",
"\"CacheServer\"",
")",
",",
"router",
":",
"router",
",",
"localShards",
":",
"make",
"(",
"map",
"[",
"uint64",
"]",
"bool",
")",
",",
"shards",
":",
"shards",
",",
"}",
"\n",
"groupcache",
".",
"RegisterPeerPicker",
"(",
"func",
"(",
")",
"groupcache",
".",
"PeerPicker",
"{",
"return",
"server",
"}",
")",
"\n",
"return",
"server",
"\n",
"}"
] |
// NewCacheServer creates a new CacheServer.
|
[
"NewCacheServer",
"creates",
"a",
"new",
"CacheServer",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cache/server/server.go#L26-L35
|
test
|
pachyderm/pachyderm
|
src/server/pps/server/api_server.go
|
authorizePipelineOp
|
func (a *apiServer) authorizePipelineOp(pachClient *client.APIClient, operation pipelineOperation, input *pps.Input, output string) error {
ctx := pachClient.Ctx()
me, err := pachClient.WhoAmI(ctx, &auth.WhoAmIRequest{})
if auth.IsErrNotActivated(err) {
return nil // Auth isn't activated, skip authorization completely
} else if err != nil {
return err
}
if input != nil {
// Check that the user is authorized to read all input repos, and write to the
// output repo (which the pipeline needs to be able to do on the user's
// behalf)
var eg errgroup.Group
done := make(map[string]struct{}) // don't double-authorize repos
pps.VisitInput(input, func(in *pps.Input) {
var repo string
if in.Pfs != nil {
repo = in.Pfs.Repo
} else {
return
}
if _, ok := done[repo]; ok {
return
}
done[repo] = struct{}{}
eg.Go(func() error {
resp, err := pachClient.Authorize(ctx, &auth.AuthorizeRequest{
Repo: repo,
Scope: auth.Scope_READER,
})
if err != nil {
return err
}
if !resp.Authorized {
return &auth.ErrNotAuthorized{
Subject: me.Username,
Repo: repo,
Required: auth.Scope_READER,
}
}
return nil
})
})
if err := eg.Wait(); err != nil {
return err
}
}
// Check that the user is authorized to write to the output repo.
// Note: authorizePipelineOp is called before CreateRepo creates a
// PipelineInfo proto in etcd, so PipelineManager won't have created an output
// repo yet, and it's possible to check that the output repo doesn't exist
// (if it did exist, we'd have to check that the user has permission to write
// to it, and this is simpler)
var required auth.Scope
switch operation {
case pipelineOpCreate:
if _, err := pachClient.InspectRepo(output); err == nil {
return fmt.Errorf("cannot overwrite repo \"%s\" with new output repo", output)
} else if !isNotFoundErr(err) {
return err
}
case pipelineOpListDatum, pipelineOpGetLogs:
required = auth.Scope_READER
case pipelineOpUpdate:
required = auth.Scope_WRITER
case pipelineOpDelete:
required = auth.Scope_OWNER
default:
return fmt.Errorf("internal error, unrecognized operation %v", operation)
}
if required != auth.Scope_NONE {
resp, err := pachClient.Authorize(ctx, &auth.AuthorizeRequest{
Repo: output,
Scope: required,
})
if err != nil {
return err
}
if !resp.Authorized {
return &auth.ErrNotAuthorized{
Subject: me.Username,
Repo: output,
Required: required,
}
}
}
return nil
}
|
go
|
func (a *apiServer) authorizePipelineOp(pachClient *client.APIClient, operation pipelineOperation, input *pps.Input, output string) error {
ctx := pachClient.Ctx()
me, err := pachClient.WhoAmI(ctx, &auth.WhoAmIRequest{})
if auth.IsErrNotActivated(err) {
return nil // Auth isn't activated, skip authorization completely
} else if err != nil {
return err
}
if input != nil {
// Check that the user is authorized to read all input repos, and write to the
// output repo (which the pipeline needs to be able to do on the user's
// behalf)
var eg errgroup.Group
done := make(map[string]struct{}) // don't double-authorize repos
pps.VisitInput(input, func(in *pps.Input) {
var repo string
if in.Pfs != nil {
repo = in.Pfs.Repo
} else {
return
}
if _, ok := done[repo]; ok {
return
}
done[repo] = struct{}{}
eg.Go(func() error {
resp, err := pachClient.Authorize(ctx, &auth.AuthorizeRequest{
Repo: repo,
Scope: auth.Scope_READER,
})
if err != nil {
return err
}
if !resp.Authorized {
return &auth.ErrNotAuthorized{
Subject: me.Username,
Repo: repo,
Required: auth.Scope_READER,
}
}
return nil
})
})
if err := eg.Wait(); err != nil {
return err
}
}
// Check that the user is authorized to write to the output repo.
// Note: authorizePipelineOp is called before CreateRepo creates a
// PipelineInfo proto in etcd, so PipelineManager won't have created an output
// repo yet, and it's possible to check that the output repo doesn't exist
// (if it did exist, we'd have to check that the user has permission to write
// to it, and this is simpler)
var required auth.Scope
switch operation {
case pipelineOpCreate:
if _, err := pachClient.InspectRepo(output); err == nil {
return fmt.Errorf("cannot overwrite repo \"%s\" with new output repo", output)
} else if !isNotFoundErr(err) {
return err
}
case pipelineOpListDatum, pipelineOpGetLogs:
required = auth.Scope_READER
case pipelineOpUpdate:
required = auth.Scope_WRITER
case pipelineOpDelete:
required = auth.Scope_OWNER
default:
return fmt.Errorf("internal error, unrecognized operation %v", operation)
}
if required != auth.Scope_NONE {
resp, err := pachClient.Authorize(ctx, &auth.AuthorizeRequest{
Repo: output,
Scope: required,
})
if err != nil {
return err
}
if !resp.Authorized {
return &auth.ErrNotAuthorized{
Subject: me.Username,
Repo: output,
Required: required,
}
}
}
return nil
}
|
[
"func",
"(",
"a",
"*",
"apiServer",
")",
"authorizePipelineOp",
"(",
"pachClient",
"*",
"client",
".",
"APIClient",
",",
"operation",
"pipelineOperation",
",",
"input",
"*",
"pps",
".",
"Input",
",",
"output",
"string",
")",
"error",
"{",
"ctx",
":=",
"pachClient",
".",
"Ctx",
"(",
")",
"\n",
"me",
",",
"err",
":=",
"pachClient",
".",
"WhoAmI",
"(",
"ctx",
",",
"&",
"auth",
".",
"WhoAmIRequest",
"{",
"}",
")",
"\n",
"if",
"auth",
".",
"IsErrNotActivated",
"(",
"err",
")",
"{",
"return",
"nil",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"input",
"!=",
"nil",
"{",
"var",
"eg",
"errgroup",
".",
"Group",
"\n",
"done",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"pps",
".",
"VisitInput",
"(",
"input",
",",
"func",
"(",
"in",
"*",
"pps",
".",
"Input",
")",
"{",
"var",
"repo",
"string",
"\n",
"if",
"in",
".",
"Pfs",
"!=",
"nil",
"{",
"repo",
"=",
"in",
".",
"Pfs",
".",
"Repo",
"\n",
"}",
"else",
"{",
"return",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"done",
"[",
"repo",
"]",
";",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"done",
"[",
"repo",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"eg",
".",
"Go",
"(",
"func",
"(",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"pachClient",
".",
"Authorize",
"(",
"ctx",
",",
"&",
"auth",
".",
"AuthorizeRequest",
"{",
"Repo",
":",
"repo",
",",
"Scope",
":",
"auth",
".",
"Scope_READER",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"resp",
".",
"Authorized",
"{",
"return",
"&",
"auth",
".",
"ErrNotAuthorized",
"{",
"Subject",
":",
"me",
".",
"Username",
",",
"Repo",
":",
"repo",
",",
"Required",
":",
"auth",
".",
"Scope_READER",
",",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}",
")",
"\n",
"if",
"err",
":=",
"eg",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"var",
"required",
"auth",
".",
"Scope",
"\n",
"switch",
"operation",
"{",
"case",
"pipelineOpCreate",
":",
"if",
"_",
",",
"err",
":=",
"pachClient",
".",
"InspectRepo",
"(",
"output",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"cannot overwrite repo \\\"%s\\\" with new output repo\"",
",",
"\\\"",
")",
"\n",
"}",
"else",
"\\\"",
"\n",
"output",
"if",
"!",
"isNotFoundErr",
"(",
"err",
")",
"{",
"return",
"err",
"\n",
"}",
"case",
"pipelineOpListDatum",
",",
"pipelineOpGetLogs",
":",
"required",
"=",
"auth",
".",
"Scope_READER",
"\n",
"case",
"pipelineOpUpdate",
":",
"required",
"=",
"auth",
".",
"Scope_WRITER",
"\n",
"}",
"\n",
"case",
"pipelineOpDelete",
":",
"required",
"=",
"auth",
".",
"Scope_OWNER",
"\n",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"internal error, unrecognized operation %v\"",
",",
"operation",
")",
"\n",
"\n",
"}"
] |
// authorizePipelineOp checks if the user indicated by 'ctx' is authorized
// to perform 'operation' on the pipeline in 'info'
|
[
"authorizePipelineOp",
"checks",
"if",
"the",
"user",
"indicated",
"by",
"ctx",
"is",
"authorized",
"to",
"perform",
"operation",
"on",
"the",
"pipeline",
"in",
"info"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/api_server.go#L377-L468
|
test
|
pachyderm/pachyderm
|
src/server/pps/server/api_server.go
|
sudo
|
func (a *apiServer) sudo(pachClient *client.APIClient, f func(*client.APIClient) error) error {
// Get PPS auth token
superUserTokenOnce.Do(func() {
b := backoff.NewExponentialBackOff()
b.MaxElapsedTime = 60 * time.Second
b.MaxInterval = 5 * time.Second
if err := backoff.Retry(func() error {
superUserTokenCol := col.NewCollection(a.env.GetEtcdClient(), ppsconsts.PPSTokenKey, nil, &types.StringValue{}, nil, nil).ReadOnly(pachClient.Ctx())
var result types.StringValue
if err := superUserTokenCol.Get("", &result); err != nil {
return err
}
superUserToken = result.Value
return nil
}, b); err != nil {
panic(fmt.Sprintf("couldn't get PPS superuser token: %v", err))
}
})
// Copy pach client, but keep ctx (to propagate cancellation). Replace token
// with superUserToken
superUserClient := pachClient.WithCtx(pachClient.Ctx())
superUserClient.SetAuthToken(superUserToken)
return f(superUserClient)
}
|
go
|
func (a *apiServer) sudo(pachClient *client.APIClient, f func(*client.APIClient) error) error {
// Get PPS auth token
superUserTokenOnce.Do(func() {
b := backoff.NewExponentialBackOff()
b.MaxElapsedTime = 60 * time.Second
b.MaxInterval = 5 * time.Second
if err := backoff.Retry(func() error {
superUserTokenCol := col.NewCollection(a.env.GetEtcdClient(), ppsconsts.PPSTokenKey, nil, &types.StringValue{}, nil, nil).ReadOnly(pachClient.Ctx())
var result types.StringValue
if err := superUserTokenCol.Get("", &result); err != nil {
return err
}
superUserToken = result.Value
return nil
}, b); err != nil {
panic(fmt.Sprintf("couldn't get PPS superuser token: %v", err))
}
})
// Copy pach client, but keep ctx (to propagate cancellation). Replace token
// with superUserToken
superUserClient := pachClient.WithCtx(pachClient.Ctx())
superUserClient.SetAuthToken(superUserToken)
return f(superUserClient)
}
|
[
"func",
"(",
"a",
"*",
"apiServer",
")",
"sudo",
"(",
"pachClient",
"*",
"client",
".",
"APIClient",
",",
"f",
"func",
"(",
"*",
"client",
".",
"APIClient",
")",
"error",
")",
"error",
"{",
"superUserTokenOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"b",
":=",
"backoff",
".",
"NewExponentialBackOff",
"(",
")",
"\n",
"b",
".",
"MaxElapsedTime",
"=",
"60",
"*",
"time",
".",
"Second",
"\n",
"b",
".",
"MaxInterval",
"=",
"5",
"*",
"time",
".",
"Second",
"\n",
"if",
"err",
":=",
"backoff",
".",
"Retry",
"(",
"func",
"(",
")",
"error",
"{",
"superUserTokenCol",
":=",
"col",
".",
"NewCollection",
"(",
"a",
".",
"env",
".",
"GetEtcdClient",
"(",
")",
",",
"ppsconsts",
".",
"PPSTokenKey",
",",
"nil",
",",
"&",
"types",
".",
"StringValue",
"{",
"}",
",",
"nil",
",",
"nil",
")",
".",
"ReadOnly",
"(",
"pachClient",
".",
"Ctx",
"(",
")",
")",
"\n",
"var",
"result",
"types",
".",
"StringValue",
"\n",
"if",
"err",
":=",
"superUserTokenCol",
".",
"Get",
"(",
"\"\"",
",",
"&",
"result",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"superUserToken",
"=",
"result",
".",
"Value",
"\n",
"return",
"nil",
"\n",
"}",
",",
"b",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"couldn't get PPS superuser token: %v\"",
",",
"err",
")",
")",
"\n",
"}",
"\n",
"}",
")",
"\n",
"superUserClient",
":=",
"pachClient",
".",
"WithCtx",
"(",
"pachClient",
".",
"Ctx",
"(",
")",
")",
"\n",
"superUserClient",
".",
"SetAuthToken",
"(",
"superUserToken",
")",
"\n",
"return",
"f",
"(",
"superUserClient",
")",
"\n",
"}"
] |
// sudo is a helper function that copies 'pachClient' grants it PPS's superuser
// token, and calls 'f' with the superuser client. This helps isolate PPS's use
// of its superuser token so that it's not widely copied and is unlikely to
// leak authority to parts of the code that aren't supposed to have it.
//
// Note that because the argument to 'f' is a superuser client, it should not
// be used to make any calls with unvalidated user input. Any such use could be
// exploited to make PPS a confused deputy
|
[
"sudo",
"is",
"a",
"helper",
"function",
"that",
"copies",
"pachClient",
"grants",
"it",
"PPS",
"s",
"superuser",
"token",
"and",
"calls",
"f",
"with",
"the",
"superuser",
"client",
".",
"This",
"helps",
"isolate",
"PPS",
"s",
"use",
"of",
"its",
"superuser",
"token",
"so",
"that",
"it",
"s",
"not",
"widely",
"copied",
"and",
"is",
"unlikely",
"to",
"leak",
"authority",
"to",
"parts",
"of",
"the",
"code",
"that",
"aren",
"t",
"supposed",
"to",
"have",
"it",
".",
"Note",
"that",
"because",
"the",
"argument",
"to",
"f",
"is",
"a",
"superuser",
"client",
"it",
"should",
"not",
"be",
"used",
"to",
"make",
"any",
"calls",
"with",
"unvalidated",
"user",
"input",
".",
"Any",
"such",
"use",
"could",
"be",
"exploited",
"to",
"make",
"PPS",
"a",
"confused",
"deputy"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/api_server.go#L1588-L1612
|
test
|
pachyderm/pachyderm
|
src/server/pps/server/api_server.go
|
setPipelineDefaults
|
func setPipelineDefaults(pipelineInfo *pps.PipelineInfo) {
now := time.Now()
if pipelineInfo.Transform.Image == "" {
pipelineInfo.Transform.Image = DefaultUserImage
}
pps.VisitInput(pipelineInfo.Input, func(input *pps.Input) {
if input.Pfs != nil {
if input.Pfs.Branch == "" {
input.Pfs.Branch = "master"
}
if input.Pfs.Name == "" {
input.Pfs.Name = input.Pfs.Repo
}
}
if input.Cron != nil {
if input.Cron.Start == nil {
start, _ := types.TimestampProto(now)
input.Cron.Start = start
}
if input.Cron.Repo == "" {
input.Cron.Repo = fmt.Sprintf("%s_%s", pipelineInfo.Pipeline.Name, input.Cron.Name)
}
}
if input.Git != nil {
if input.Git.Branch == "" {
input.Git.Branch = "master"
}
if input.Git.Name == "" {
// We know URL looks like:
// "https://github.com/sjezewski/testgithook.git",
tokens := strings.Split(path.Base(input.Git.URL), ".")
input.Git.Name = tokens[0]
}
}
})
if pipelineInfo.OutputBranch == "" {
// Output branches default to master
pipelineInfo.OutputBranch = "master"
}
if pipelineInfo.CacheSize == "" {
pipelineInfo.CacheSize = "64M"
}
if pipelineInfo.ResourceRequests == nil && pipelineInfo.CacheSize != "" {
pipelineInfo.ResourceRequests = &pps.ResourceSpec{
Memory: pipelineInfo.CacheSize,
}
}
if pipelineInfo.MaxQueueSize < 1 {
pipelineInfo.MaxQueueSize = 1
}
if pipelineInfo.DatumTries == 0 {
pipelineInfo.DatumTries = DefaultDatumTries
}
}
|
go
|
func setPipelineDefaults(pipelineInfo *pps.PipelineInfo) {
now := time.Now()
if pipelineInfo.Transform.Image == "" {
pipelineInfo.Transform.Image = DefaultUserImage
}
pps.VisitInput(pipelineInfo.Input, func(input *pps.Input) {
if input.Pfs != nil {
if input.Pfs.Branch == "" {
input.Pfs.Branch = "master"
}
if input.Pfs.Name == "" {
input.Pfs.Name = input.Pfs.Repo
}
}
if input.Cron != nil {
if input.Cron.Start == nil {
start, _ := types.TimestampProto(now)
input.Cron.Start = start
}
if input.Cron.Repo == "" {
input.Cron.Repo = fmt.Sprintf("%s_%s", pipelineInfo.Pipeline.Name, input.Cron.Name)
}
}
if input.Git != nil {
if input.Git.Branch == "" {
input.Git.Branch = "master"
}
if input.Git.Name == "" {
// We know URL looks like:
// "https://github.com/sjezewski/testgithook.git",
tokens := strings.Split(path.Base(input.Git.URL), ".")
input.Git.Name = tokens[0]
}
}
})
if pipelineInfo.OutputBranch == "" {
// Output branches default to master
pipelineInfo.OutputBranch = "master"
}
if pipelineInfo.CacheSize == "" {
pipelineInfo.CacheSize = "64M"
}
if pipelineInfo.ResourceRequests == nil && pipelineInfo.CacheSize != "" {
pipelineInfo.ResourceRequests = &pps.ResourceSpec{
Memory: pipelineInfo.CacheSize,
}
}
if pipelineInfo.MaxQueueSize < 1 {
pipelineInfo.MaxQueueSize = 1
}
if pipelineInfo.DatumTries == 0 {
pipelineInfo.DatumTries = DefaultDatumTries
}
}
|
[
"func",
"setPipelineDefaults",
"(",
"pipelineInfo",
"*",
"pps",
".",
"PipelineInfo",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"if",
"pipelineInfo",
".",
"Transform",
".",
"Image",
"==",
"\"\"",
"{",
"pipelineInfo",
".",
"Transform",
".",
"Image",
"=",
"DefaultUserImage",
"\n",
"}",
"\n",
"pps",
".",
"VisitInput",
"(",
"pipelineInfo",
".",
"Input",
",",
"func",
"(",
"input",
"*",
"pps",
".",
"Input",
")",
"{",
"if",
"input",
".",
"Pfs",
"!=",
"nil",
"{",
"if",
"input",
".",
"Pfs",
".",
"Branch",
"==",
"\"\"",
"{",
"input",
".",
"Pfs",
".",
"Branch",
"=",
"\"master\"",
"\n",
"}",
"\n",
"if",
"input",
".",
"Pfs",
".",
"Name",
"==",
"\"\"",
"{",
"input",
".",
"Pfs",
".",
"Name",
"=",
"input",
".",
"Pfs",
".",
"Repo",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"input",
".",
"Cron",
"!=",
"nil",
"{",
"if",
"input",
".",
"Cron",
".",
"Start",
"==",
"nil",
"{",
"start",
",",
"_",
":=",
"types",
".",
"TimestampProto",
"(",
"now",
")",
"\n",
"input",
".",
"Cron",
".",
"Start",
"=",
"start",
"\n",
"}",
"\n",
"if",
"input",
".",
"Cron",
".",
"Repo",
"==",
"\"\"",
"{",
"input",
".",
"Cron",
".",
"Repo",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"%s_%s\"",
",",
"pipelineInfo",
".",
"Pipeline",
".",
"Name",
",",
"input",
".",
"Cron",
".",
"Name",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"input",
".",
"Git",
"!=",
"nil",
"{",
"if",
"input",
".",
"Git",
".",
"Branch",
"==",
"\"\"",
"{",
"input",
".",
"Git",
".",
"Branch",
"=",
"\"master\"",
"\n",
"}",
"\n",
"if",
"input",
".",
"Git",
".",
"Name",
"==",
"\"\"",
"{",
"tokens",
":=",
"strings",
".",
"Split",
"(",
"path",
".",
"Base",
"(",
"input",
".",
"Git",
".",
"URL",
")",
",",
"\".\"",
")",
"\n",
"input",
".",
"Git",
".",
"Name",
"=",
"tokens",
"[",
"0",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"}",
")",
"\n",
"if",
"pipelineInfo",
".",
"OutputBranch",
"==",
"\"\"",
"{",
"pipelineInfo",
".",
"OutputBranch",
"=",
"\"master\"",
"\n",
"}",
"\n",
"if",
"pipelineInfo",
".",
"CacheSize",
"==",
"\"\"",
"{",
"pipelineInfo",
".",
"CacheSize",
"=",
"\"64M\"",
"\n",
"}",
"\n",
"if",
"pipelineInfo",
".",
"ResourceRequests",
"==",
"nil",
"&&",
"pipelineInfo",
".",
"CacheSize",
"!=",
"\"\"",
"{",
"pipelineInfo",
".",
"ResourceRequests",
"=",
"&",
"pps",
".",
"ResourceSpec",
"{",
"Memory",
":",
"pipelineInfo",
".",
"CacheSize",
",",
"}",
"\n",
"}",
"\n",
"if",
"pipelineInfo",
".",
"MaxQueueSize",
"<",
"1",
"{",
"pipelineInfo",
".",
"MaxQueueSize",
"=",
"1",
"\n",
"}",
"\n",
"if",
"pipelineInfo",
".",
"DatumTries",
"==",
"0",
"{",
"pipelineInfo",
".",
"DatumTries",
"=",
"DefaultDatumTries",
"\n",
"}",
"\n",
"}"
] |
// setPipelineDefaults sets the default values for a pipeline info
|
[
"setPipelineDefaults",
"sets",
"the",
"default",
"values",
"for",
"a",
"pipeline",
"info"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/api_server.go#L1970-L2023
|
test
|
pachyderm/pachyderm
|
src/server/pps/server/api_server.go
|
incrementGCGeneration
|
func (a *apiServer) incrementGCGeneration(ctx context.Context) error {
resp, err := a.env.GetEtcdClient().Get(ctx, client.GCGenerationKey)
if err != nil {
return err
}
if resp.Count == 0 {
// If the generation number does not exist, create it.
// It's important that the new generation is 1, as the first
// generation is assumed to be 0.
if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, "1"); err != nil {
return err
}
} else {
oldGen, err := strconv.Atoi(string(resp.Kvs[0].Value))
if err != nil {
return err
}
newGen := oldGen + 1
if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, strconv.Itoa(newGen)); err != nil {
return err
}
}
return nil
}
|
go
|
func (a *apiServer) incrementGCGeneration(ctx context.Context) error {
resp, err := a.env.GetEtcdClient().Get(ctx, client.GCGenerationKey)
if err != nil {
return err
}
if resp.Count == 0 {
// If the generation number does not exist, create it.
// It's important that the new generation is 1, as the first
// generation is assumed to be 0.
if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, "1"); err != nil {
return err
}
} else {
oldGen, err := strconv.Atoi(string(resp.Kvs[0].Value))
if err != nil {
return err
}
newGen := oldGen + 1
if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, strconv.Itoa(newGen)); err != nil {
return err
}
}
return nil
}
|
[
"func",
"(",
"a",
"*",
"apiServer",
")",
"incrementGCGeneration",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"a",
".",
"env",
".",
"GetEtcdClient",
"(",
")",
".",
"Get",
"(",
"ctx",
",",
"client",
".",
"GCGenerationKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"resp",
".",
"Count",
"==",
"0",
"{",
"if",
"_",
",",
"err",
":=",
"a",
".",
"env",
".",
"GetEtcdClient",
"(",
")",
".",
"Put",
"(",
"ctx",
",",
"client",
".",
"GCGenerationKey",
",",
"\"1\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"oldGen",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"string",
"(",
"resp",
".",
"Kvs",
"[",
"0",
"]",
".",
"Value",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"newGen",
":=",
"oldGen",
"+",
"1",
"\n",
"if",
"_",
",",
"err",
":=",
"a",
".",
"env",
".",
"GetEtcdClient",
"(",
")",
".",
"Put",
"(",
"ctx",
",",
"client",
".",
"GCGenerationKey",
",",
"strconv",
".",
"Itoa",
"(",
"newGen",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// incrementGCGeneration increments the GC generation number in etcd
|
[
"incrementGCGeneration",
"increments",
"the",
"GC",
"generation",
"number",
"in",
"etcd"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/api_server.go#L2692-L2716
|
test
|
pachyderm/pachyderm
|
src/server/debug/server/server.go
|
NewDebugServer
|
func NewDebugServer(name string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) debug.DebugServer {
return &debugServer{
name: name,
etcdClient: etcdClient,
etcdPrefix: etcdPrefix,
workerGrpcPort: workerGrpcPort,
}
}
|
go
|
func NewDebugServer(name string, etcdClient *etcd.Client, etcdPrefix string, workerGrpcPort uint16) debug.DebugServer {
return &debugServer{
name: name,
etcdClient: etcdClient,
etcdPrefix: etcdPrefix,
workerGrpcPort: workerGrpcPort,
}
}
|
[
"func",
"NewDebugServer",
"(",
"name",
"string",
",",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"etcdPrefix",
"string",
",",
"workerGrpcPort",
"uint16",
")",
"debug",
".",
"DebugServer",
"{",
"return",
"&",
"debugServer",
"{",
"name",
":",
"name",
",",
"etcdClient",
":",
"etcdClient",
",",
"etcdPrefix",
":",
"etcdPrefix",
",",
"workerGrpcPort",
":",
"workerGrpcPort",
",",
"}",
"\n",
"}"
] |
// NewDebugServer creates a new server that serves the debug api over GRPC
|
[
"NewDebugServer",
"creates",
"a",
"new",
"server",
"that",
"serves",
"the",
"debug",
"api",
"over",
"GRPC"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/debug/server/server.go#L22-L29
|
test
|
pachyderm/pachyderm
|
src/client/health.go
|
Health
|
func (c APIClient) Health() error {
_, err := c.healthClient.Health(c.Ctx(), &types.Empty{})
return grpcutil.ScrubGRPC(err)
}
|
go
|
func (c APIClient) Health() error {
_, err := c.healthClient.Health(c.Ctx(), &types.Empty{})
return grpcutil.ScrubGRPC(err)
}
|
[
"func",
"(",
"c",
"APIClient",
")",
"Health",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"healthClient",
".",
"Health",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"types",
".",
"Empty",
"{",
"}",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}"
] |
// Health health checks pachd, it returns an error if pachd isn't healthy.
|
[
"Health",
"health",
"checks",
"pachd",
"it",
"returns",
"an",
"error",
"if",
"pachd",
"isn",
"t",
"healthy",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/health.go#L10-L13
|
test
|
pachyderm/pachyderm
|
src/server/pfs/server/obj_block_api_server.go
|
newObjBlockAPIServer
|
func newObjBlockAPIServer(dir string, cacheBytes int64, etcdAddress string, objClient obj.Client, test bool) (*objBlockAPIServer, error) {
// defensive measure to make sure storage is working and error early if it's not
// this is where we'll find out if the credentials have been misconfigured
if err := obj.TestStorage(context.Background(), objClient); err != nil {
return nil, err
}
oneCacheShare := cacheBytes / (objectCacheShares + tagCacheShares + objectInfoCacheShares + blockCacheShares)
s := &objBlockAPIServer{
Logger: log.NewLogger("pfs.BlockAPI.Obj"),
dir: dir,
objClient: objClient,
objectIndexes: make(map[string]*pfsclient.ObjectIndex),
objectCacheBytes: oneCacheShare * objectCacheShares,
}
objectGroupName := "object"
tagGroupName := "tag"
objectInfoGroupName := "objectInfo"
blockGroupName := "block"
if test {
uuid := uuid.New()
objectGroupName += uuid
tagGroupName += uuid
objectInfoGroupName += uuid
blockGroupName += uuid
}
s.objectCache = groupcache.NewGroup(objectGroupName, oneCacheShare*objectCacheShares, groupcache.GetterFunc(s.objectGetter))
s.tagCache = groupcache.NewGroup(tagGroupName, oneCacheShare*tagCacheShares, groupcache.GetterFunc(s.tagGetter))
s.objectInfoCache = groupcache.NewGroup(objectInfoGroupName, oneCacheShare*objectInfoCacheShares, groupcache.GetterFunc(s.objectInfoGetter))
s.blockCache = groupcache.NewGroup(blockGroupName, oneCacheShare*blockCacheShares, groupcache.GetterFunc(s.blockGetter))
if !test {
RegisterCacheStats("tag", &s.tagCache.Stats)
RegisterCacheStats("object", &s.objectCache.Stats)
RegisterCacheStats("object_info", &s.objectInfoCache.Stats)
}
go s.watchGC(etcdAddress)
return s, nil
}
|
go
|
func newObjBlockAPIServer(dir string, cacheBytes int64, etcdAddress string, objClient obj.Client, test bool) (*objBlockAPIServer, error) {
// defensive measure to make sure storage is working and error early if it's not
// this is where we'll find out if the credentials have been misconfigured
if err := obj.TestStorage(context.Background(), objClient); err != nil {
return nil, err
}
oneCacheShare := cacheBytes / (objectCacheShares + tagCacheShares + objectInfoCacheShares + blockCacheShares)
s := &objBlockAPIServer{
Logger: log.NewLogger("pfs.BlockAPI.Obj"),
dir: dir,
objClient: objClient,
objectIndexes: make(map[string]*pfsclient.ObjectIndex),
objectCacheBytes: oneCacheShare * objectCacheShares,
}
objectGroupName := "object"
tagGroupName := "tag"
objectInfoGroupName := "objectInfo"
blockGroupName := "block"
if test {
uuid := uuid.New()
objectGroupName += uuid
tagGroupName += uuid
objectInfoGroupName += uuid
blockGroupName += uuid
}
s.objectCache = groupcache.NewGroup(objectGroupName, oneCacheShare*objectCacheShares, groupcache.GetterFunc(s.objectGetter))
s.tagCache = groupcache.NewGroup(tagGroupName, oneCacheShare*tagCacheShares, groupcache.GetterFunc(s.tagGetter))
s.objectInfoCache = groupcache.NewGroup(objectInfoGroupName, oneCacheShare*objectInfoCacheShares, groupcache.GetterFunc(s.objectInfoGetter))
s.blockCache = groupcache.NewGroup(blockGroupName, oneCacheShare*blockCacheShares, groupcache.GetterFunc(s.blockGetter))
if !test {
RegisterCacheStats("tag", &s.tagCache.Stats)
RegisterCacheStats("object", &s.objectCache.Stats)
RegisterCacheStats("object_info", &s.objectInfoCache.Stats)
}
go s.watchGC(etcdAddress)
return s, nil
}
|
[
"func",
"newObjBlockAPIServer",
"(",
"dir",
"string",
",",
"cacheBytes",
"int64",
",",
"etcdAddress",
"string",
",",
"objClient",
"obj",
".",
"Client",
",",
"test",
"bool",
")",
"(",
"*",
"objBlockAPIServer",
",",
"error",
")",
"{",
"if",
"err",
":=",
"obj",
".",
"TestStorage",
"(",
"context",
".",
"Background",
"(",
")",
",",
"objClient",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"oneCacheShare",
":=",
"cacheBytes",
"/",
"(",
"objectCacheShares",
"+",
"tagCacheShares",
"+",
"objectInfoCacheShares",
"+",
"blockCacheShares",
")",
"\n",
"s",
":=",
"&",
"objBlockAPIServer",
"{",
"Logger",
":",
"log",
".",
"NewLogger",
"(",
"\"pfs.BlockAPI.Obj\"",
")",
",",
"dir",
":",
"dir",
",",
"objClient",
":",
"objClient",
",",
"objectIndexes",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"pfsclient",
".",
"ObjectIndex",
")",
",",
"objectCacheBytes",
":",
"oneCacheShare",
"*",
"objectCacheShares",
",",
"}",
"\n",
"objectGroupName",
":=",
"\"object\"",
"\n",
"tagGroupName",
":=",
"\"tag\"",
"\n",
"objectInfoGroupName",
":=",
"\"objectInfo\"",
"\n",
"blockGroupName",
":=",
"\"block\"",
"\n",
"if",
"test",
"{",
"uuid",
":=",
"uuid",
".",
"New",
"(",
")",
"\n",
"objectGroupName",
"+=",
"uuid",
"\n",
"tagGroupName",
"+=",
"uuid",
"\n",
"objectInfoGroupName",
"+=",
"uuid",
"\n",
"blockGroupName",
"+=",
"uuid",
"\n",
"}",
"\n",
"s",
".",
"objectCache",
"=",
"groupcache",
".",
"NewGroup",
"(",
"objectGroupName",
",",
"oneCacheShare",
"*",
"objectCacheShares",
",",
"groupcache",
".",
"GetterFunc",
"(",
"s",
".",
"objectGetter",
")",
")",
"\n",
"s",
".",
"tagCache",
"=",
"groupcache",
".",
"NewGroup",
"(",
"tagGroupName",
",",
"oneCacheShare",
"*",
"tagCacheShares",
",",
"groupcache",
".",
"GetterFunc",
"(",
"s",
".",
"tagGetter",
")",
")",
"\n",
"s",
".",
"objectInfoCache",
"=",
"groupcache",
".",
"NewGroup",
"(",
"objectInfoGroupName",
",",
"oneCacheShare",
"*",
"objectInfoCacheShares",
",",
"groupcache",
".",
"GetterFunc",
"(",
"s",
".",
"objectInfoGetter",
")",
")",
"\n",
"s",
".",
"blockCache",
"=",
"groupcache",
".",
"NewGroup",
"(",
"blockGroupName",
",",
"oneCacheShare",
"*",
"blockCacheShares",
",",
"groupcache",
".",
"GetterFunc",
"(",
"s",
".",
"blockGetter",
")",
")",
"\n",
"if",
"!",
"test",
"{",
"RegisterCacheStats",
"(",
"\"tag\"",
",",
"&",
"s",
".",
"tagCache",
".",
"Stats",
")",
"\n",
"RegisterCacheStats",
"(",
"\"object\"",
",",
"&",
"s",
".",
"objectCache",
".",
"Stats",
")",
"\n",
"RegisterCacheStats",
"(",
"\"object_info\"",
",",
"&",
"s",
".",
"objectInfoCache",
".",
"Stats",
")",
"\n",
"}",
"\n",
"go",
"s",
".",
"watchGC",
"(",
"etcdAddress",
")",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] |
// In test mode, we use unique names for cache groups, since we might want
// to run multiple block servers locally, which would conflict if groups
// had the same name. We also do not report stats to prometheus
|
[
"In",
"test",
"mode",
"we",
"use",
"unique",
"names",
"for",
"cache",
"groups",
"since",
"we",
"might",
"want",
"to",
"run",
"multiple",
"block",
"servers",
"locally",
"which",
"would",
"conflict",
"if",
"groups",
"had",
"the",
"same",
"name",
".",
"We",
"also",
"do",
"not",
"report",
"stats",
"to",
"prometheus"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/server/obj_block_api_server.go#L69-L110
|
test
|
pachyderm/pachyderm
|
src/server/pfs/server/obj_block_api_server.go
|
watchGC
|
func (s *objBlockAPIServer) watchGC(etcdAddress string) {
b := backoff.NewInfiniteBackOff()
backoff.RetryNotify(func() error {
etcdClient, err := etcd.New(etcd.Config{
Endpoints: []string{etcdAddress},
DialOptions: client.DefaultDialOptions(),
})
if err != nil {
return fmt.Errorf("error instantiating etcd client: %v", err)
}
watcher, err := watch.NewWatcher(context.Background(), etcdClient, "", client.GCGenerationKey, nil)
if err != nil {
return fmt.Errorf("error instantiating watch stream from generation number: %v", err)
}
defer watcher.Close()
for {
ev, ok := <-watcher.Watch()
if ev.Err != nil {
return fmt.Errorf("error from generation number watch: %v", ev.Err)
}
if !ok {
return fmt.Errorf("generation number watch stream closed unexpectedly")
}
newGen, err := strconv.Atoi(string(ev.Value))
if err != nil {
return fmt.Errorf("error converting the generation number: %v", err)
}
s.setGeneration(newGen)
}
}, b, func(err error, d time.Duration) error {
logrus.Errorf("error running GC watcher in block server: %v; retrying in %s", err, d)
return nil
})
}
|
go
|
func (s *objBlockAPIServer) watchGC(etcdAddress string) {
b := backoff.NewInfiniteBackOff()
backoff.RetryNotify(func() error {
etcdClient, err := etcd.New(etcd.Config{
Endpoints: []string{etcdAddress},
DialOptions: client.DefaultDialOptions(),
})
if err != nil {
return fmt.Errorf("error instantiating etcd client: %v", err)
}
watcher, err := watch.NewWatcher(context.Background(), etcdClient, "", client.GCGenerationKey, nil)
if err != nil {
return fmt.Errorf("error instantiating watch stream from generation number: %v", err)
}
defer watcher.Close()
for {
ev, ok := <-watcher.Watch()
if ev.Err != nil {
return fmt.Errorf("error from generation number watch: %v", ev.Err)
}
if !ok {
return fmt.Errorf("generation number watch stream closed unexpectedly")
}
newGen, err := strconv.Atoi(string(ev.Value))
if err != nil {
return fmt.Errorf("error converting the generation number: %v", err)
}
s.setGeneration(newGen)
}
}, b, func(err error, d time.Duration) error {
logrus.Errorf("error running GC watcher in block server: %v; retrying in %s", err, d)
return nil
})
}
|
[
"func",
"(",
"s",
"*",
"objBlockAPIServer",
")",
"watchGC",
"(",
"etcdAddress",
"string",
")",
"{",
"b",
":=",
"backoff",
".",
"NewInfiniteBackOff",
"(",
")",
"\n",
"backoff",
".",
"RetryNotify",
"(",
"func",
"(",
")",
"error",
"{",
"etcdClient",
",",
"err",
":=",
"etcd",
".",
"New",
"(",
"etcd",
".",
"Config",
"{",
"Endpoints",
":",
"[",
"]",
"string",
"{",
"etcdAddress",
"}",
",",
"DialOptions",
":",
"client",
".",
"DefaultDialOptions",
"(",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"error instantiating etcd client: %v\"",
",",
"err",
")",
"\n",
"}",
"\n",
"watcher",
",",
"err",
":=",
"watch",
".",
"NewWatcher",
"(",
"context",
".",
"Background",
"(",
")",
",",
"etcdClient",
",",
"\"\"",
",",
"client",
".",
"GCGenerationKey",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"error instantiating watch stream from generation number: %v\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"watcher",
".",
"Close",
"(",
")",
"\n",
"for",
"{",
"ev",
",",
"ok",
":=",
"<-",
"watcher",
".",
"Watch",
"(",
")",
"\n",
"if",
"ev",
".",
"Err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"error from generation number watch: %v\"",
",",
"ev",
".",
"Err",
")",
"\n",
"}",
"\n",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"generation number watch stream closed unexpectedly\"",
")",
"\n",
"}",
"\n",
"newGen",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"string",
"(",
"ev",
".",
"Value",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"error converting the generation number: %v\"",
",",
"err",
")",
"\n",
"}",
"\n",
"s",
".",
"setGeneration",
"(",
"newGen",
")",
"\n",
"}",
"\n",
"}",
",",
"b",
",",
"func",
"(",
"err",
"error",
",",
"d",
"time",
".",
"Duration",
")",
"error",
"{",
"logrus",
".",
"Errorf",
"(",
"\"error running GC watcher in block server: %v; retrying in %s\"",
",",
"err",
",",
"d",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
] |
// watchGC watches for GC runs and invalidate all cache when GC happens.
|
[
"watchGC",
"watches",
"for",
"GC",
"runs",
"and",
"invalidate",
"all",
"cache",
"when",
"GC",
"happens",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/server/obj_block_api_server.go#L113-L148
|
test
|
pachyderm/pachyderm
|
src/server/pfs/server/obj_block_api_server.go
|
splitKey
|
func (s *objBlockAPIServer) splitKey(key string) string {
gen := s.getGeneration()
if len(key) < prefixLength {
return fmt.Sprintf("%s.%d", key, gen)
}
return fmt.Sprintf("%s.%s.%d", key[:prefixLength], key[prefixLength:], gen)
}
|
go
|
func (s *objBlockAPIServer) splitKey(key string) string {
gen := s.getGeneration()
if len(key) < prefixLength {
return fmt.Sprintf("%s.%d", key, gen)
}
return fmt.Sprintf("%s.%s.%d", key[:prefixLength], key[prefixLength:], gen)
}
|
[
"func",
"(",
"s",
"*",
"objBlockAPIServer",
")",
"splitKey",
"(",
"key",
"string",
")",
"string",
"{",
"gen",
":=",
"s",
".",
"getGeneration",
"(",
")",
"\n",
"if",
"len",
"(",
"key",
")",
"<",
"prefixLength",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s.%d\"",
",",
"key",
",",
"gen",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s.%s.%d\"",
",",
"key",
"[",
":",
"prefixLength",
"]",
",",
"key",
"[",
"prefixLength",
":",
"]",
",",
"gen",
")",
"\n",
"}"
] |
// splitKey splits a key into the format we want, and also postpends
// the generation number
|
[
"splitKey",
"splits",
"a",
"key",
"into",
"the",
"format",
"we",
"want",
"and",
"also",
"postpends",
"the",
"generation",
"number"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/server/obj_block_api_server.go#L1101-L1107
|
test
|
pachyderm/pachyderm
|
src/server/pkg/tabwriter/tabwriter.go
|
NewWriter
|
func NewWriter(w io.Writer, header string) *Writer {
if header[len(header)-1] != '\n' {
panic("header must end in a new line")
}
tabwriter := ansiterm.NewTabWriter(w, 0, 1, 1, ' ', 0)
tabwriter.Write([]byte(header))
return &Writer{
w: tabwriter,
lines: 1, // 1 because we just printed the header
header: []byte(header),
}
}
|
go
|
func NewWriter(w io.Writer, header string) *Writer {
if header[len(header)-1] != '\n' {
panic("header must end in a new line")
}
tabwriter := ansiterm.NewTabWriter(w, 0, 1, 1, ' ', 0)
tabwriter.Write([]byte(header))
return &Writer{
w: tabwriter,
lines: 1, // 1 because we just printed the header
header: []byte(header),
}
}
|
[
"func",
"NewWriter",
"(",
"w",
"io",
".",
"Writer",
",",
"header",
"string",
")",
"*",
"Writer",
"{",
"if",
"header",
"[",
"len",
"(",
"header",
")",
"-",
"1",
"]",
"!=",
"'\\n'",
"{",
"panic",
"(",
"\"header must end in a new line\"",
")",
"\n",
"}",
"\n",
"tabwriter",
":=",
"ansiterm",
".",
"NewTabWriter",
"(",
"w",
",",
"0",
",",
"1",
",",
"1",
",",
"' '",
",",
"0",
")",
"\n",
"tabwriter",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"header",
")",
")",
"\n",
"return",
"&",
"Writer",
"{",
"w",
":",
"tabwriter",
",",
"lines",
":",
"1",
",",
"header",
":",
"[",
"]",
"byte",
"(",
"header",
")",
",",
"}",
"\n",
"}"
] |
// NewWriter returns a new Writer, it will flush when
// it gets termHeight many lines, including the header line.
// The header line will be reprinted termHeight many lines have been written.
// NewStreamingWriter will panic if it's given a header that doesn't end in \n.
|
[
"NewWriter",
"returns",
"a",
"new",
"Writer",
"it",
"will",
"flush",
"when",
"it",
"gets",
"termHeight",
"many",
"lines",
"including",
"the",
"header",
"line",
".",
"The",
"header",
"line",
"will",
"be",
"reprinted",
"termHeight",
"many",
"lines",
"have",
"been",
"written",
".",
"NewStreamingWriter",
"will",
"panic",
"if",
"it",
"s",
"given",
"a",
"header",
"that",
"doesn",
"t",
"end",
"in",
"\\",
"n",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/tabwriter/tabwriter.go#L28-L39
|
test
|
pachyderm/pachyderm
|
src/server/pkg/tabwriter/tabwriter.go
|
Write
|
func (w *Writer) Write(buf []byte) (int, error) {
if w.lines >= termHeight {
if err := w.Flush(); err != nil {
return 0, err
}
if _, err := w.w.Write(w.header); err != nil {
return 0, err
}
w.lines++
}
w.lines += bytes.Count(buf, []byte{'\n'})
return w.w.Write(buf)
}
|
go
|
func (w *Writer) Write(buf []byte) (int, error) {
if w.lines >= termHeight {
if err := w.Flush(); err != nil {
return 0, err
}
if _, err := w.w.Write(w.header); err != nil {
return 0, err
}
w.lines++
}
w.lines += bytes.Count(buf, []byte{'\n'})
return w.w.Write(buf)
}
|
[
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"w",
".",
"lines",
">=",
"termHeight",
"{",
"if",
"err",
":=",
"w",
".",
"Flush",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"w",
".",
"w",
".",
"Write",
"(",
"w",
".",
"header",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"w",
".",
"lines",
"++",
"\n",
"}",
"\n",
"w",
".",
"lines",
"+=",
"bytes",
".",
"Count",
"(",
"buf",
",",
"[",
"]",
"byte",
"{",
"'\\n'",
"}",
")",
"\n",
"return",
"w",
".",
"w",
".",
"Write",
"(",
"buf",
")",
"\n",
"}"
] |
// Write writes a line to the tabwriter.
|
[
"Write",
"writes",
"a",
"line",
"to",
"the",
"tabwriter",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/tabwriter/tabwriter.go#L42-L54
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintRepoHeader
|
func PrintRepoHeader(w io.Writer, printAuth bool) {
if printAuth {
fmt.Fprint(w, RepoAuthHeader)
return
}
fmt.Fprint(w, RepoHeader)
}
|
go
|
func PrintRepoHeader(w io.Writer, printAuth bool) {
if printAuth {
fmt.Fprint(w, RepoAuthHeader)
return
}
fmt.Fprint(w, RepoHeader)
}
|
[
"func",
"PrintRepoHeader",
"(",
"w",
"io",
".",
"Writer",
",",
"printAuth",
"bool",
")",
"{",
"if",
"printAuth",
"{",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"RepoAuthHeader",
")",
"\n",
"return",
"\n",
"}",
"\n",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"RepoHeader",
")",
"\n",
"}"
] |
// PrintRepoHeader prints a repo header.
|
[
"PrintRepoHeader",
"prints",
"a",
"repo",
"header",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L28-L34
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintRepoInfo
|
func PrintRepoInfo(w io.Writer, repoInfo *pfs.RepoInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", repoInfo.Repo.Name)
if fullTimestamps {
fmt.Fprintf(w, "%s\t", repoInfo.Created.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(repoInfo.Created))
}
fmt.Fprintf(w, "%s\t", units.BytesSize(float64(repoInfo.SizeBytes)))
if repoInfo.AuthInfo != nil {
fmt.Fprintf(w, "%s\t", repoInfo.AuthInfo.AccessLevel.String())
}
fmt.Fprintln(w)
}
|
go
|
func PrintRepoInfo(w io.Writer, repoInfo *pfs.RepoInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", repoInfo.Repo.Name)
if fullTimestamps {
fmt.Fprintf(w, "%s\t", repoInfo.Created.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(repoInfo.Created))
}
fmt.Fprintf(w, "%s\t", units.BytesSize(float64(repoInfo.SizeBytes)))
if repoInfo.AuthInfo != nil {
fmt.Fprintf(w, "%s\t", repoInfo.AuthInfo.AccessLevel.String())
}
fmt.Fprintln(w)
}
|
[
"func",
"PrintRepoInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"repoInfo",
"*",
"pfs",
".",
"RepoInfo",
",",
"fullTimestamps",
"bool",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"repoInfo",
".",
"Repo",
".",
"Name",
"\n",
"if",
"fullTimestamps",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"}",
"else",
"repoInfo",
".",
"Created",
".",
"String",
"(",
")",
"\n",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"}",
"\n",
"pretty",
".",
"Ago",
"(",
"repoInfo",
".",
"Created",
")",
"\n",
"}"
] |
// PrintRepoInfo pretty-prints repo info.
|
[
"PrintRepoInfo",
"pretty",
"-",
"prints",
"repo",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L37-L49
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintDetailedRepoInfo
|
func PrintDetailedRepoInfo(repoInfo *PrintableRepoInfo) error {
template, err := template.New("RepoInfo").Funcs(funcMap).Parse(
`Name: {{.Repo.Name}}{{if .Description}}
Description: {{.Description}}{{end}}{{if .FullTimestamps}}
Created: {{.Created}}{{else}}
Created: {{prettyAgo .Created}}{{end}}
Size of HEAD on master: {{prettySize .SizeBytes}}{{if .AuthInfo}}
Access level: {{ .AuthInfo.AccessLevel.String }}{{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, repoInfo)
if err != nil {
return err
}
return nil
}
|
go
|
func PrintDetailedRepoInfo(repoInfo *PrintableRepoInfo) error {
template, err := template.New("RepoInfo").Funcs(funcMap).Parse(
`Name: {{.Repo.Name}}{{if .Description}}
Description: {{.Description}}{{end}}{{if .FullTimestamps}}
Created: {{.Created}}{{else}}
Created: {{prettyAgo .Created}}{{end}}
Size of HEAD on master: {{prettySize .SizeBytes}}{{if .AuthInfo}}
Access level: {{ .AuthInfo.AccessLevel.String }}{{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, repoInfo)
if err != nil {
return err
}
return nil
}
|
[
"func",
"PrintDetailedRepoInfo",
"(",
"repoInfo",
"*",
"PrintableRepoInfo",
")",
"error",
"{",
"template",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"RepoInfo\"",
")",
".",
"Funcs",
"(",
"funcMap",
")",
".",
"Parse",
"(",
"`Name: {{.Repo.Name}}{{if .Description}}Description: {{.Description}}{{end}}{{if .FullTimestamps}}Created: {{.Created}}{{else}}Created: {{prettyAgo .Created}}{{end}}Size of HEAD on master: {{prettySize .SizeBytes}}{{if .AuthInfo}}Access level: {{ .AuthInfo.AccessLevel.String }}{{end}}`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"template",
".",
"Execute",
"(",
"os",
".",
"Stdout",
",",
"repoInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// PrintDetailedRepoInfo pretty-prints detailed repo info.
|
[
"PrintDetailedRepoInfo",
"pretty",
"-",
"prints",
"detailed",
"repo",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L66-L83
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintBranch
|
func PrintBranch(w io.Writer, branchInfo *pfs.BranchInfo) {
fmt.Fprintf(w, "%s\t", branchInfo.Branch.Name)
if branchInfo.Head != nil {
fmt.Fprintf(w, "%s\t\n", branchInfo.Head.ID)
} else {
fmt.Fprintf(w, "-\t\n")
}
}
|
go
|
func PrintBranch(w io.Writer, branchInfo *pfs.BranchInfo) {
fmt.Fprintf(w, "%s\t", branchInfo.Branch.Name)
if branchInfo.Head != nil {
fmt.Fprintf(w, "%s\t\n", branchInfo.Head.ID)
} else {
fmt.Fprintf(w, "-\t\n")
}
}
|
[
"func",
"PrintBranch",
"(",
"w",
"io",
".",
"Writer",
",",
"branchInfo",
"*",
"pfs",
".",
"BranchInfo",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"branchInfo",
".",
"Branch",
".",
"Name",
"\n",
"}"
] |
// PrintBranch pretty-prints a Branch.
|
[
"PrintBranch",
"pretty",
"-",
"prints",
"a",
"Branch",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L91-L98
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintCommitInfo
|
func PrintCommitInfo(w io.Writer, commitInfo *pfs.CommitInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", commitInfo.Commit.Repo.Name)
fmt.Fprintf(w, "%s\t", commitInfo.Branch.Name)
fmt.Fprintf(w, "%s\t", commitInfo.Commit.ID)
if commitInfo.ParentCommit != nil {
fmt.Fprintf(w, "%s\t", commitInfo.ParentCommit.ID)
} else {
fmt.Fprint(w, "<none>\t")
}
if fullTimestamps {
fmt.Fprintf(w, "%s\t", commitInfo.Started.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(commitInfo.Started))
}
if commitInfo.Finished != nil {
fmt.Fprintf(w, fmt.Sprintf("%s\t", pretty.TimeDifference(commitInfo.Started, commitInfo.Finished)))
fmt.Fprintf(w, "%s\t\n", units.BytesSize(float64(commitInfo.SizeBytes)))
} else {
fmt.Fprintf(w, "-\t")
// Open commits don't have meaningful size information
fmt.Fprintf(w, "-\t\n")
}
}
|
go
|
func PrintCommitInfo(w io.Writer, commitInfo *pfs.CommitInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", commitInfo.Commit.Repo.Name)
fmt.Fprintf(w, "%s\t", commitInfo.Branch.Name)
fmt.Fprintf(w, "%s\t", commitInfo.Commit.ID)
if commitInfo.ParentCommit != nil {
fmt.Fprintf(w, "%s\t", commitInfo.ParentCommit.ID)
} else {
fmt.Fprint(w, "<none>\t")
}
if fullTimestamps {
fmt.Fprintf(w, "%s\t", commitInfo.Started.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(commitInfo.Started))
}
if commitInfo.Finished != nil {
fmt.Fprintf(w, fmt.Sprintf("%s\t", pretty.TimeDifference(commitInfo.Started, commitInfo.Finished)))
fmt.Fprintf(w, "%s\t\n", units.BytesSize(float64(commitInfo.SizeBytes)))
} else {
fmt.Fprintf(w, "-\t")
// Open commits don't have meaningful size information
fmt.Fprintf(w, "-\t\n")
}
}
|
[
"func",
"PrintCommitInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"commitInfo",
"*",
"pfs",
".",
"CommitInfo",
",",
"fullTimestamps",
"bool",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"commitInfo",
".",
"Commit",
".",
"Repo",
".",
"Name",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"commitInfo",
".",
"Branch",
".",
"Name",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"commitInfo",
".",
"Commit",
".",
"ID",
"\n",
"}"
] |
// PrintCommitInfo pretty-prints commit info.
|
[
"PrintCommitInfo",
"pretty",
"-",
"prints",
"commit",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L106-L128
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintDetailedCommitInfo
|
func PrintDetailedCommitInfo(commitInfo *PrintableCommitInfo) error {
template, err := template.New("CommitInfo").Funcs(funcMap).Parse(
`Commit: {{.Commit.Repo.Name}}@{{.Commit.ID}}{{if .Branch}}
Original Branch: {{.Branch.Name}}{{end}}{{if .Description}}
Description: {{.Description}}{{end}}{{if .ParentCommit}}
Parent: {{.ParentCommit.ID}}{{end}}{{if .FullTimestamps}}
Started: {{.Started}}{{else}}
Started: {{prettyAgo .Started}}{{end}}{{if .Finished}}{{if .FullTimestamps}}
Finished: {{.Finished}}{{else}}
Finished: {{prettyAgo .Finished}}{{end}}{{end}}
Size: {{prettySize .SizeBytes}}{{if .Provenance}}
Provenance: {{range .Provenance}} {{.Commit.Repo.Name}}@{{.Commit.ID}} ({{.Branch.Name}}) {{end}} {{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, commitInfo)
if err != nil {
return err
}
return nil
}
|
go
|
func PrintDetailedCommitInfo(commitInfo *PrintableCommitInfo) error {
template, err := template.New("CommitInfo").Funcs(funcMap).Parse(
`Commit: {{.Commit.Repo.Name}}@{{.Commit.ID}}{{if .Branch}}
Original Branch: {{.Branch.Name}}{{end}}{{if .Description}}
Description: {{.Description}}{{end}}{{if .ParentCommit}}
Parent: {{.ParentCommit.ID}}{{end}}{{if .FullTimestamps}}
Started: {{.Started}}{{else}}
Started: {{prettyAgo .Started}}{{end}}{{if .Finished}}{{if .FullTimestamps}}
Finished: {{.Finished}}{{else}}
Finished: {{prettyAgo .Finished}}{{end}}{{end}}
Size: {{prettySize .SizeBytes}}{{if .Provenance}}
Provenance: {{range .Provenance}} {{.Commit.Repo.Name}}@{{.Commit.ID}} ({{.Branch.Name}}) {{end}} {{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, commitInfo)
if err != nil {
return err
}
return nil
}
|
[
"func",
"PrintDetailedCommitInfo",
"(",
"commitInfo",
"*",
"PrintableCommitInfo",
")",
"error",
"{",
"template",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"CommitInfo\"",
")",
".",
"Funcs",
"(",
"funcMap",
")",
".",
"Parse",
"(",
"`Commit: {{.Commit.Repo.Name}}@{{.Commit.ID}}{{if .Branch}}Original Branch: {{.Branch.Name}}{{end}}{{if .Description}}Description: {{.Description}}{{end}}{{if .ParentCommit}}Parent: {{.ParentCommit.ID}}{{end}}{{if .FullTimestamps}}Started: {{.Started}}{{else}}Started: {{prettyAgo .Started}}{{end}}{{if .Finished}}{{if .FullTimestamps}}Finished: {{.Finished}}{{else}}Finished: {{prettyAgo .Finished}}{{end}}{{end}}Size: {{prettySize .SizeBytes}}{{if .Provenance}}Provenance: {{range .Provenance}} {{.Commit.Repo.Name}}@{{.Commit.ID}} ({{.Branch.Name}}) {{end}} {{end}}`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"template",
".",
"Execute",
"(",
"os",
".",
"Stdout",
",",
"commitInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// PrintDetailedCommitInfo pretty-prints detailed commit info.
|
[
"PrintDetailedCommitInfo",
"pretty",
"-",
"prints",
"detailed",
"commit",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L145-L166
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintFileInfo
|
func PrintFileInfo(w io.Writer, fileInfo *pfs.FileInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", fileInfo.File.Commit.ID)
fmt.Fprintf(w, "%s\t", fileInfo.File.Path)
if fileInfo.FileType == pfs.FileType_FILE {
fmt.Fprint(w, "file\t")
} else {
fmt.Fprint(w, "dir\t")
}
if fileInfo.Committed == nil {
fmt.Fprintf(w, "-\t")
} else if fullTimestamps {
fmt.Fprintf(w, "%s\t", fileInfo.Committed.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(fileInfo.Committed))
}
fmt.Fprintf(w, "%s\t\n", units.BytesSize(float64(fileInfo.SizeBytes)))
}
|
go
|
func PrintFileInfo(w io.Writer, fileInfo *pfs.FileInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", fileInfo.File.Commit.ID)
fmt.Fprintf(w, "%s\t", fileInfo.File.Path)
if fileInfo.FileType == pfs.FileType_FILE {
fmt.Fprint(w, "file\t")
} else {
fmt.Fprint(w, "dir\t")
}
if fileInfo.Committed == nil {
fmt.Fprintf(w, "-\t")
} else if fullTimestamps {
fmt.Fprintf(w, "%s\t", fileInfo.Committed.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(fileInfo.Committed))
}
fmt.Fprintf(w, "%s\t\n", units.BytesSize(float64(fileInfo.SizeBytes)))
}
|
[
"func",
"PrintFileInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"fileInfo",
"*",
"pfs",
".",
"FileInfo",
",",
"fullTimestamps",
"bool",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"fileInfo",
".",
"File",
".",
"Commit",
".",
"ID",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"fileInfo",
".",
"File",
".",
"Path",
"\n",
"if",
"fileInfo",
".",
"FileType",
"==",
"pfs",
".",
"FileType_FILE",
"{",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"\"file\\t\"",
")",
"\n",
"}",
"else",
"\\t",
"\n",
"}"
] |
// PrintFileInfo pretty-prints file info.
// If recurse is false and directory size is 0, display "-" instead
// If fast is true and file size is 0, display "-" instead
|
[
"PrintFileInfo",
"pretty",
"-",
"prints",
"file",
"info",
".",
"If",
"recurse",
"is",
"false",
"and",
"directory",
"size",
"is",
"0",
"display",
"-",
"instead",
"If",
"fast",
"is",
"true",
"and",
"file",
"size",
"is",
"0",
"display",
"-",
"instead"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L176-L192
|
test
|
pachyderm/pachyderm
|
src/server/pfs/pretty/pretty.go
|
PrintDetailedFileInfo
|
func PrintDetailedFileInfo(fileInfo *pfs.FileInfo) error {
template, err := template.New("FileInfo").Funcs(funcMap).Parse(
`Path: {{.File.Path}}
Type: {{fileType .FileType}}
Size: {{prettySize .SizeBytes}}
Children: {{range .Children}} {{.}} {{end}}
`)
if err != nil {
return err
}
return template.Execute(os.Stdout, fileInfo)
}
|
go
|
func PrintDetailedFileInfo(fileInfo *pfs.FileInfo) error {
template, err := template.New("FileInfo").Funcs(funcMap).Parse(
`Path: {{.File.Path}}
Type: {{fileType .FileType}}
Size: {{prettySize .SizeBytes}}
Children: {{range .Children}} {{.}} {{end}}
`)
if err != nil {
return err
}
return template.Execute(os.Stdout, fileInfo)
}
|
[
"func",
"PrintDetailedFileInfo",
"(",
"fileInfo",
"*",
"pfs",
".",
"FileInfo",
")",
"error",
"{",
"template",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"FileInfo\"",
")",
".",
"Funcs",
"(",
"funcMap",
")",
".",
"Parse",
"(",
"`Path: {{.File.Path}}Type: {{fileType .FileType}}Size: {{prettySize .SizeBytes}}Children: {{range .Children}} {{.}} {{end}}`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"template",
".",
"Execute",
"(",
"os",
".",
"Stdout",
",",
"fileInfo",
")",
"\n",
"}"
] |
// PrintDetailedFileInfo pretty-prints detailed file info.
|
[
"PrintDetailedFileInfo",
"pretty",
"-",
"prints",
"detailed",
"file",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pretty/pretty.go#L195-L206
|
test
|
pachyderm/pachyderm
|
src/server/pkg/ancestry/ancestry.go
|
Add
|
func Add(s string, ancestors int) string {
return fmt.Sprintf("%s~%d", s, ancestors)
}
|
go
|
func Add(s string, ancestors int) string {
return fmt.Sprintf("%s~%d", s, ancestors)
}
|
[
"func",
"Add",
"(",
"s",
"string",
",",
"ancestors",
"int",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s~%d\"",
",",
"s",
",",
"ancestors",
")",
"\n",
"}"
] |
// Add adds an ancestry reference to the given string.
|
[
"Add",
"adds",
"an",
"ancestry",
"reference",
"to",
"the",
"given",
"string",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/ancestry/ancestry.go#L54-L56
|
test
|
pachyderm/pachyderm
|
src/server/pkg/backoff/retry.go
|
RetryNotify
|
func RetryNotify(operation Operation, b BackOff, notify Notify) error {
var err error
var next time.Duration
b.Reset()
for {
if err = operation(); err == nil {
return nil
}
if next = b.NextBackOff(); next == Stop {
return err
}
if notify != nil {
if err := notify(err, next); err != nil {
return err
}
}
time.Sleep(next)
}
}
|
go
|
func RetryNotify(operation Operation, b BackOff, notify Notify) error {
var err error
var next time.Duration
b.Reset()
for {
if err = operation(); err == nil {
return nil
}
if next = b.NextBackOff(); next == Stop {
return err
}
if notify != nil {
if err := notify(err, next); err != nil {
return err
}
}
time.Sleep(next)
}
}
|
[
"func",
"RetryNotify",
"(",
"operation",
"Operation",
",",
"b",
"BackOff",
",",
"notify",
"Notify",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"var",
"next",
"time",
".",
"Duration",
"\n",
"b",
".",
"Reset",
"(",
")",
"\n",
"for",
"{",
"if",
"err",
"=",
"operation",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"next",
"=",
"b",
".",
"NextBackOff",
"(",
")",
";",
"next",
"==",
"Stop",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"notify",
"!=",
"nil",
"{",
"if",
"err",
":=",
"notify",
"(",
"err",
",",
"next",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"next",
")",
"\n",
"}",
"\n",
"}"
] |
// RetryNotify calls notify function with the error and wait duration
// for each failed attempt before sleep.
|
[
"RetryNotify",
"calls",
"notify",
"function",
"with",
"the",
"error",
"and",
"wait",
"duration",
"for",
"each",
"failed",
"attempt",
"before",
"sleep",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/backoff/retry.go#L29-L51
|
test
|
pachyderm/pachyderm
|
src/server/pkg/hashtree/cache.go
|
Get
|
func (c *MergeCache) Get(id int64, w io.Writer, filter Filter) (retErr error) {
r, err := c.Cache.Get(fmt.Sprint(id))
if err != nil {
return err
}
defer func() {
if err := r.Close(); err != nil && retErr == nil {
retErr = err
}
}()
return NewWriter(w).Copy(NewReader(r, filter))
}
|
go
|
func (c *MergeCache) Get(id int64, w io.Writer, filter Filter) (retErr error) {
r, err := c.Cache.Get(fmt.Sprint(id))
if err != nil {
return err
}
defer func() {
if err := r.Close(); err != nil && retErr == nil {
retErr = err
}
}()
return NewWriter(w).Copy(NewReader(r, filter))
}
|
[
"func",
"(",
"c",
"*",
"MergeCache",
")",
"Get",
"(",
"id",
"int64",
",",
"w",
"io",
".",
"Writer",
",",
"filter",
"Filter",
")",
"(",
"retErr",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"Cache",
".",
"Get",
"(",
"fmt",
".",
"Sprint",
"(",
"id",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"r",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"&&",
"retErr",
"==",
"nil",
"{",
"retErr",
"=",
"err",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"return",
"NewWriter",
"(",
"w",
")",
".",
"Copy",
"(",
"NewReader",
"(",
"r",
",",
"filter",
")",
")",
"\n",
"}"
] |
// Get does a filtered write of id's hashtree to the passed in io.Writer.
|
[
"Get",
"does",
"a",
"filtered",
"write",
"of",
"id",
"s",
"hashtree",
"to",
"the",
"passed",
"in",
"io",
".",
"Writer",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/cache.go#L56-L67
|
test
|
pachyderm/pachyderm
|
src/server/pkg/hashtree/cache.go
|
Delete
|
func (c *MergeCache) Delete(id int64) error {
return c.Cache.Delete(fmt.Sprint(id))
}
|
go
|
func (c *MergeCache) Delete(id int64) error {
return c.Cache.Delete(fmt.Sprint(id))
}
|
[
"func",
"(",
"c",
"*",
"MergeCache",
")",
"Delete",
"(",
"id",
"int64",
")",
"error",
"{",
"return",
"c",
".",
"Cache",
".",
"Delete",
"(",
"fmt",
".",
"Sprint",
"(",
"id",
")",
")",
"\n",
"}"
] |
// Delete deletes a hashtree from the cache.
|
[
"Delete",
"deletes",
"a",
"hashtree",
"from",
"the",
"cache",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/cache.go#L70-L72
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintJobInfo
|
func PrintJobInfo(w io.Writer, jobInfo *ppsclient.JobInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", jobInfo.Job.ID)
fmt.Fprintf(w, "%s\t", jobInfo.Pipeline.Name)
if fullTimestamps {
fmt.Fprintf(w, "%s\t", jobInfo.Started.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(jobInfo.Started))
}
if jobInfo.Finished != nil {
fmt.Fprintf(w, "%s\t", pretty.TimeDifference(jobInfo.Started, jobInfo.Finished))
} else {
fmt.Fprintf(w, "-\t")
}
fmt.Fprintf(w, "%d\t", jobInfo.Restart)
if jobInfo.DataRecovered != 0 {
fmt.Fprintf(w, "%d + %d + %d / %d\t", jobInfo.DataProcessed, jobInfo.DataSkipped, jobInfo.DataRecovered, jobInfo.DataTotal)
} else {
fmt.Fprintf(w, "%d + %d / %d\t", jobInfo.DataProcessed, jobInfo.DataSkipped, jobInfo.DataTotal)
}
fmt.Fprintf(w, "%s\t", pretty.Size(jobInfo.Stats.DownloadBytes))
fmt.Fprintf(w, "%s\t", pretty.Size(jobInfo.Stats.UploadBytes))
if jobInfo.State == ppsclient.JobState_JOB_FAILURE {
fmt.Fprintf(w, "%s: %s\t\n", jobState(jobInfo.State), safeTrim(jobInfo.Reason, jobReasonLen))
} else {
fmt.Fprintf(w, "%s\t\n", jobState(jobInfo.State))
}
}
|
go
|
func PrintJobInfo(w io.Writer, jobInfo *ppsclient.JobInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", jobInfo.Job.ID)
fmt.Fprintf(w, "%s\t", jobInfo.Pipeline.Name)
if fullTimestamps {
fmt.Fprintf(w, "%s\t", jobInfo.Started.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(jobInfo.Started))
}
if jobInfo.Finished != nil {
fmt.Fprintf(w, "%s\t", pretty.TimeDifference(jobInfo.Started, jobInfo.Finished))
} else {
fmt.Fprintf(w, "-\t")
}
fmt.Fprintf(w, "%d\t", jobInfo.Restart)
if jobInfo.DataRecovered != 0 {
fmt.Fprintf(w, "%d + %d + %d / %d\t", jobInfo.DataProcessed, jobInfo.DataSkipped, jobInfo.DataRecovered, jobInfo.DataTotal)
} else {
fmt.Fprintf(w, "%d + %d / %d\t", jobInfo.DataProcessed, jobInfo.DataSkipped, jobInfo.DataTotal)
}
fmt.Fprintf(w, "%s\t", pretty.Size(jobInfo.Stats.DownloadBytes))
fmt.Fprintf(w, "%s\t", pretty.Size(jobInfo.Stats.UploadBytes))
if jobInfo.State == ppsclient.JobState_JOB_FAILURE {
fmt.Fprintf(w, "%s: %s\t\n", jobState(jobInfo.State), safeTrim(jobInfo.Reason, jobReasonLen))
} else {
fmt.Fprintf(w, "%s\t\n", jobState(jobInfo.State))
}
}
|
[
"func",
"PrintJobInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"jobInfo",
"*",
"ppsclient",
".",
"JobInfo",
",",
"fullTimestamps",
"bool",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"jobInfo",
".",
"Job",
".",
"ID",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"jobInfo",
".",
"Pipeline",
".",
"Name",
"\n",
"if",
"fullTimestamps",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"}",
"else",
"jobInfo",
".",
"Started",
".",
"String",
"(",
")",
"\n",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"}",
"\n",
"pretty",
".",
"Ago",
"(",
"jobInfo",
".",
"Started",
")",
"\n",
"if",
"jobInfo",
".",
"Finished",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"}",
"else",
"pretty",
".",
"TimeDifference",
"(",
"jobInfo",
".",
"Started",
",",
"jobInfo",
".",
"Finished",
")",
"\n",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"-\\t\"",
")",
"\n",
"}",
"\n",
"}"
] |
// PrintJobInfo pretty-prints job info.
|
[
"PrintJobInfo",
"pretty",
"-",
"prints",
"job",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L46-L72
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintPipelineInfo
|
func PrintPipelineInfo(w io.Writer, pipelineInfo *ppsclient.PipelineInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", pipelineInfo.Pipeline.Name)
fmt.Fprintf(w, "%s\t", ShorthandInput(pipelineInfo.Input))
if fullTimestamps {
fmt.Fprintf(w, "%s\t", pipelineInfo.CreatedAt.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(pipelineInfo.CreatedAt))
}
fmt.Fprintf(w, "%s / %s\t\n", pipelineState(pipelineInfo.State), jobState(pipelineInfo.LastJobState))
}
|
go
|
func PrintPipelineInfo(w io.Writer, pipelineInfo *ppsclient.PipelineInfo, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", pipelineInfo.Pipeline.Name)
fmt.Fprintf(w, "%s\t", ShorthandInput(pipelineInfo.Input))
if fullTimestamps {
fmt.Fprintf(w, "%s\t", pipelineInfo.CreatedAt.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(pipelineInfo.CreatedAt))
}
fmt.Fprintf(w, "%s / %s\t\n", pipelineState(pipelineInfo.State), jobState(pipelineInfo.LastJobState))
}
|
[
"func",
"PrintPipelineInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"pipelineInfo",
"*",
"ppsclient",
".",
"PipelineInfo",
",",
"fullTimestamps",
"bool",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"pipelineInfo",
".",
"Pipeline",
".",
"Name",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"ShorthandInput",
"(",
"pipelineInfo",
".",
"Input",
")",
"\n",
"}"
] |
// PrintPipelineInfo pretty-prints pipeline info.
|
[
"PrintPipelineInfo",
"pretty",
"-",
"prints",
"pipeline",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L80-L89
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintWorkerStatus
|
func PrintWorkerStatus(w io.Writer, workerStatus *ppsclient.WorkerStatus, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", workerStatus.WorkerID)
fmt.Fprintf(w, "%s\t", workerStatus.JobID)
for _, datum := range workerStatus.Data {
fmt.Fprintf(w, datum.Path)
}
fmt.Fprintf(w, "\t")
if fullTimestamps {
fmt.Fprintf(w, "%s\t", workerStatus.Started.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(workerStatus.Started))
}
fmt.Fprintf(w, "%d\t\n", workerStatus.QueueSize)
}
|
go
|
func PrintWorkerStatus(w io.Writer, workerStatus *ppsclient.WorkerStatus, fullTimestamps bool) {
fmt.Fprintf(w, "%s\t", workerStatus.WorkerID)
fmt.Fprintf(w, "%s\t", workerStatus.JobID)
for _, datum := range workerStatus.Data {
fmt.Fprintf(w, datum.Path)
}
fmt.Fprintf(w, "\t")
if fullTimestamps {
fmt.Fprintf(w, "%s\t", workerStatus.Started.String())
} else {
fmt.Fprintf(w, "%s\t", pretty.Ago(workerStatus.Started))
}
fmt.Fprintf(w, "%d\t\n", workerStatus.QueueSize)
}
|
[
"func",
"PrintWorkerStatus",
"(",
"w",
"io",
".",
"Writer",
",",
"workerStatus",
"*",
"ppsclient",
".",
"WorkerStatus",
",",
"fullTimestamps",
"bool",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"workerStatus",
".",
"WorkerID",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t\"",
",",
"\\t",
")",
"\n",
"workerStatus",
".",
"JobID",
"\n",
"for",
"_",
",",
"datum",
":=",
"range",
"workerStatus",
".",
"Data",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"datum",
".",
"Path",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"\\t\"",
")",
"\n",
"}"
] |
// PrintWorkerStatus pretty prints a worker status.
|
[
"PrintWorkerStatus",
"pretty",
"prints",
"a",
"worker",
"status",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L97-L110
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintDetailedJobInfo
|
func PrintDetailedJobInfo(jobInfo *PrintableJobInfo) error {
template, err := template.New("JobInfo").Funcs(funcMap).Parse(
`ID: {{.Job.ID}} {{if .Pipeline}}
Pipeline: {{.Pipeline.Name}} {{end}} {{if .ParentJob}}
Parent: {{.ParentJob.ID}} {{end}}{{if .FullTimestamps}}
Started: {{.Started}}{{else}}
Started: {{prettyAgo .Started}} {{end}}{{if .Finished}}
Duration: {{prettyTimeDifference .Started .Finished}} {{end}}
State: {{jobState .State}}
Reason: {{.Reason}}
Processed: {{.DataProcessed}}
Failed: {{.DataFailed}}
Skipped: {{.DataSkipped}}
Recovered: {{.DataRecovered}}
Total: {{.DataTotal}}
Data Downloaded: {{prettySize .Stats.DownloadBytes}}
Data Uploaded: {{prettySize .Stats.UploadBytes}}
Download Time: {{prettyDuration .Stats.DownloadTime}}
Process Time: {{prettyDuration .Stats.ProcessTime}}
Upload Time: {{prettyDuration .Stats.UploadTime}}
Datum Timeout: {{.DatumTimeout}}
Job Timeout: {{.JobTimeout}}
Worker Status:
{{workerStatus .}}Restarts: {{.Restart}}
ParallelismSpec: {{.ParallelismSpec}}
{{ if .ResourceRequests }}ResourceRequests:
CPU: {{ .ResourceRequests.Cpu }}
Memory: {{ .ResourceRequests.Memory }} {{end}}
{{ if .ResourceLimits }}ResourceLimits:
CPU: {{ .ResourceLimits.Cpu }}
Memory: {{ .ResourceLimits.Memory }}
{{ if .ResourceLimits.Gpu }}GPU:
Type: {{ .ResourceLimits.Gpu.Type }}
Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}
{{ if .Service }}Service:
{{ if .Service.InternalPort }}InternalPort: {{ .Service.InternalPort }} {{end}}
{{ if .Service.ExternalPort }}ExternalPort: {{ .Service.ExternalPort }} {{end}} {{end}}Input:
{{jobInput .}}
Transform:
{{prettyTransform .Transform}} {{if .OutputCommit}}
Output Commit: {{.OutputCommit.ID}} {{end}} {{ if .StatsCommit }}
Stats Commit: {{.StatsCommit.ID}} {{end}} {{ if .Egress }}
Egress: {{.Egress.URL}} {{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, jobInfo)
if err != nil {
return err
}
return nil
}
|
go
|
func PrintDetailedJobInfo(jobInfo *PrintableJobInfo) error {
template, err := template.New("JobInfo").Funcs(funcMap).Parse(
`ID: {{.Job.ID}} {{if .Pipeline}}
Pipeline: {{.Pipeline.Name}} {{end}} {{if .ParentJob}}
Parent: {{.ParentJob.ID}} {{end}}{{if .FullTimestamps}}
Started: {{.Started}}{{else}}
Started: {{prettyAgo .Started}} {{end}}{{if .Finished}}
Duration: {{prettyTimeDifference .Started .Finished}} {{end}}
State: {{jobState .State}}
Reason: {{.Reason}}
Processed: {{.DataProcessed}}
Failed: {{.DataFailed}}
Skipped: {{.DataSkipped}}
Recovered: {{.DataRecovered}}
Total: {{.DataTotal}}
Data Downloaded: {{prettySize .Stats.DownloadBytes}}
Data Uploaded: {{prettySize .Stats.UploadBytes}}
Download Time: {{prettyDuration .Stats.DownloadTime}}
Process Time: {{prettyDuration .Stats.ProcessTime}}
Upload Time: {{prettyDuration .Stats.UploadTime}}
Datum Timeout: {{.DatumTimeout}}
Job Timeout: {{.JobTimeout}}
Worker Status:
{{workerStatus .}}Restarts: {{.Restart}}
ParallelismSpec: {{.ParallelismSpec}}
{{ if .ResourceRequests }}ResourceRequests:
CPU: {{ .ResourceRequests.Cpu }}
Memory: {{ .ResourceRequests.Memory }} {{end}}
{{ if .ResourceLimits }}ResourceLimits:
CPU: {{ .ResourceLimits.Cpu }}
Memory: {{ .ResourceLimits.Memory }}
{{ if .ResourceLimits.Gpu }}GPU:
Type: {{ .ResourceLimits.Gpu.Type }}
Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}
{{ if .Service }}Service:
{{ if .Service.InternalPort }}InternalPort: {{ .Service.InternalPort }} {{end}}
{{ if .Service.ExternalPort }}ExternalPort: {{ .Service.ExternalPort }} {{end}} {{end}}Input:
{{jobInput .}}
Transform:
{{prettyTransform .Transform}} {{if .OutputCommit}}
Output Commit: {{.OutputCommit.ID}} {{end}} {{ if .StatsCommit }}
Stats Commit: {{.StatsCommit.ID}} {{end}} {{ if .Egress }}
Egress: {{.Egress.URL}} {{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, jobInfo)
if err != nil {
return err
}
return nil
}
|
[
"func",
"PrintDetailedJobInfo",
"(",
"jobInfo",
"*",
"PrintableJobInfo",
")",
"error",
"{",
"template",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"JobInfo\"",
")",
".",
"Funcs",
"(",
"funcMap",
")",
".",
"Parse",
"(",
"`ID: {{.Job.ID}} {{if .Pipeline}}Pipeline: {{.Pipeline.Name}} {{end}} {{if .ParentJob}}Parent: {{.ParentJob.ID}} {{end}}{{if .FullTimestamps}}Started: {{.Started}}{{else}}Started: {{prettyAgo .Started}} {{end}}{{if .Finished}}Duration: {{prettyTimeDifference .Started .Finished}} {{end}}State: {{jobState .State}}Reason: {{.Reason}}Processed: {{.DataProcessed}}Failed: {{.DataFailed}}Skipped: {{.DataSkipped}}Recovered: {{.DataRecovered}}Total: {{.DataTotal}}Data Downloaded: {{prettySize .Stats.DownloadBytes}}Data Uploaded: {{prettySize .Stats.UploadBytes}}Download Time: {{prettyDuration .Stats.DownloadTime}}Process Time: {{prettyDuration .Stats.ProcessTime}}Upload Time: {{prettyDuration .Stats.UploadTime}}Datum Timeout: {{.DatumTimeout}}Job Timeout: {{.JobTimeout}}Worker Status:{{workerStatus .}}Restarts: {{.Restart}}ParallelismSpec: {{.ParallelismSpec}}{{ if .ResourceRequests }}ResourceRequests: CPU: {{ .ResourceRequests.Cpu }} Memory: {{ .ResourceRequests.Memory }} {{end}}{{ if .ResourceLimits }}ResourceLimits: CPU: {{ .ResourceLimits.Cpu }} Memory: {{ .ResourceLimits.Memory }} {{ if .ResourceLimits.Gpu }}GPU: Type: {{ .ResourceLimits.Gpu.Type }} Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}{{ if .Service }}Service:\t{{ if .Service.InternalPort }}InternalPort: {{ .Service.InternalPort }} {{end}}\t{{ if .Service.ExternalPort }}ExternalPort: {{ .Service.ExternalPort }} {{end}} {{end}}Input:{{jobInput .}}Transform:{{prettyTransform .Transform}} {{if .OutputCommit}}Output Commit: {{.OutputCommit.ID}} {{end}} {{ if .StatsCommit }}Stats Commit: {{.StatsCommit.ID}} {{end}} {{ if .Egress }}Egress: {{.Egress.URL}} {{end}}`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"template",
".",
"Execute",
"(",
"os",
".",
"Stdout",
",",
"jobInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// PrintDetailedJobInfo pretty-prints detailed job info.
|
[
"PrintDetailedJobInfo",
"pretty",
"-",
"prints",
"detailed",
"job",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L127-L179
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintDetailedPipelineInfo
|
func PrintDetailedPipelineInfo(pipelineInfo *PrintablePipelineInfo) error {
template, err := template.New("PipelineInfo").Funcs(funcMap).Parse(
`Name: {{.Pipeline.Name}}{{if .Description}}
Description: {{.Description}}{{end}}{{if .FullTimestamps }}
Created: {{.CreatedAt}}{{ else }}
Created: {{prettyAgo .CreatedAt}} {{end}}
State: {{pipelineState .State}}
Stopped: {{ .Stopped }}
Reason: {{.Reason}}
Parallelism Spec: {{.ParallelismSpec}}
{{ if .ResourceRequests }}ResourceRequests:
CPU: {{ .ResourceRequests.Cpu }}
Memory: {{ .ResourceRequests.Memory }} {{end}}
{{ if .ResourceLimits }}ResourceLimits:
CPU: {{ .ResourceLimits.Cpu }}
Memory: {{ .ResourceLimits.Memory }}
{{ if .ResourceLimits.Gpu }}GPU:
Type: {{ .ResourceLimits.Gpu.Type }}
Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}
Datum Timeout: {{.DatumTimeout}}
Job Timeout: {{.JobTimeout}}
Input:
{{pipelineInput .PipelineInfo}}
{{ if .GithookURL }}Githook URL: {{.GithookURL}} {{end}}
Output Branch: {{.OutputBranch}}
Transform:
{{prettyTransform .Transform}}
{{ if .Egress }}Egress: {{.Egress.URL}} {{end}}
{{if .RecentError}} Recent Error: {{.RecentError}} {{end}}
Job Counts:
{{jobCounts .JobCounts}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, pipelineInfo)
if err != nil {
return err
}
return nil
}
|
go
|
func PrintDetailedPipelineInfo(pipelineInfo *PrintablePipelineInfo) error {
template, err := template.New("PipelineInfo").Funcs(funcMap).Parse(
`Name: {{.Pipeline.Name}}{{if .Description}}
Description: {{.Description}}{{end}}{{if .FullTimestamps }}
Created: {{.CreatedAt}}{{ else }}
Created: {{prettyAgo .CreatedAt}} {{end}}
State: {{pipelineState .State}}
Stopped: {{ .Stopped }}
Reason: {{.Reason}}
Parallelism Spec: {{.ParallelismSpec}}
{{ if .ResourceRequests }}ResourceRequests:
CPU: {{ .ResourceRequests.Cpu }}
Memory: {{ .ResourceRequests.Memory }} {{end}}
{{ if .ResourceLimits }}ResourceLimits:
CPU: {{ .ResourceLimits.Cpu }}
Memory: {{ .ResourceLimits.Memory }}
{{ if .ResourceLimits.Gpu }}GPU:
Type: {{ .ResourceLimits.Gpu.Type }}
Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}
Datum Timeout: {{.DatumTimeout}}
Job Timeout: {{.JobTimeout}}
Input:
{{pipelineInput .PipelineInfo}}
{{ if .GithookURL }}Githook URL: {{.GithookURL}} {{end}}
Output Branch: {{.OutputBranch}}
Transform:
{{prettyTransform .Transform}}
{{ if .Egress }}Egress: {{.Egress.URL}} {{end}}
{{if .RecentError}} Recent Error: {{.RecentError}} {{end}}
Job Counts:
{{jobCounts .JobCounts}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, pipelineInfo)
if err != nil {
return err
}
return nil
}
|
[
"func",
"PrintDetailedPipelineInfo",
"(",
"pipelineInfo",
"*",
"PrintablePipelineInfo",
")",
"error",
"{",
"template",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"PipelineInfo\"",
")",
".",
"Funcs",
"(",
"funcMap",
")",
".",
"Parse",
"(",
"`Name: {{.Pipeline.Name}}{{if .Description}}Description: {{.Description}}{{end}}{{if .FullTimestamps }}Created: {{.CreatedAt}}{{ else }}Created: {{prettyAgo .CreatedAt}} {{end}}State: {{pipelineState .State}}Stopped: {{ .Stopped }}Reason: {{.Reason}}Parallelism Spec: {{.ParallelismSpec}}{{ if .ResourceRequests }}ResourceRequests: CPU: {{ .ResourceRequests.Cpu }} Memory: {{ .ResourceRequests.Memory }} {{end}}{{ if .ResourceLimits }}ResourceLimits: CPU: {{ .ResourceLimits.Cpu }} Memory: {{ .ResourceLimits.Memory }} {{ if .ResourceLimits.Gpu }}GPU: Type: {{ .ResourceLimits.Gpu.Type }} Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}Datum Timeout: {{.DatumTimeout}}Job Timeout: {{.JobTimeout}}Input:{{pipelineInput .PipelineInfo}}{{ if .GithookURL }}Githook URL: {{.GithookURL}} {{end}}Output Branch: {{.OutputBranch}}Transform:{{prettyTransform .Transform}}{{ if .Egress }}Egress: {{.Egress.URL}} {{end}}{{if .RecentError}} Recent Error: {{.RecentError}} {{end}}Job Counts:{{jobCounts .JobCounts}}`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"template",
".",
"Execute",
"(",
"os",
".",
"Stdout",
",",
"pipelineInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// PrintDetailedPipelineInfo pretty-prints detailed pipeline info.
|
[
"PrintDetailedPipelineInfo",
"pretty",
"-",
"prints",
"detailed",
"pipeline",
"info",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L196-L236
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintDatumInfo
|
func PrintDatumInfo(w io.Writer, datumInfo *ppsclient.DatumInfo) {
totalTime := "-"
if datumInfo.Stats != nil {
totalTime = units.HumanDuration(client.GetDatumTotalTime(datumInfo.Stats))
}
fmt.Fprintf(w, "%s\t%s\t%s\n", datumInfo.Datum.ID, datumState(datumInfo.State), totalTime)
}
|
go
|
func PrintDatumInfo(w io.Writer, datumInfo *ppsclient.DatumInfo) {
totalTime := "-"
if datumInfo.Stats != nil {
totalTime = units.HumanDuration(client.GetDatumTotalTime(datumInfo.Stats))
}
fmt.Fprintf(w, "%s\t%s\t%s\n", datumInfo.Datum.ID, datumState(datumInfo.State), totalTime)
}
|
[
"func",
"PrintDatumInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"datumInfo",
"*",
"ppsclient",
".",
"DatumInfo",
")",
"{",
"totalTime",
":=",
"\"-\"",
"\n",
"if",
"datumInfo",
".",
"Stats",
"!=",
"nil",
"{",
"totalTime",
"=",
"units",
".",
"HumanDuration",
"(",
"client",
".",
"GetDatumTotalTime",
"(",
"datumInfo",
".",
"Stats",
")",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"%s\\t%s\\t%s\\n\"",
",",
"\\t",
",",
"\\t",
",",
"\\n",
")",
"\n",
"}"
] |
// PrintDatumInfo pretty-prints file info.
// If recurse is false and directory size is 0, display "-" instead
// If fast is true and file size is 0, display "-" instead
|
[
"PrintDatumInfo",
"pretty",
"-",
"prints",
"file",
"info",
".",
"If",
"recurse",
"is",
"false",
"and",
"directory",
"size",
"is",
"0",
"display",
"-",
"instead",
"If",
"fast",
"is",
"true",
"and",
"file",
"size",
"is",
"0",
"display",
"-",
"instead"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L246-L252
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintDetailedDatumInfo
|
func PrintDetailedDatumInfo(w io.Writer, datumInfo *ppsclient.DatumInfo) {
fmt.Fprintf(w, "ID\t%s\n", datumInfo.Datum.ID)
fmt.Fprintf(w, "Job ID\t%s\n", datumInfo.Datum.Job.ID)
fmt.Fprintf(w, "State\t%s\n", datumInfo.State)
fmt.Fprintf(w, "Data Downloaded\t%s\n", pretty.Size(datumInfo.Stats.DownloadBytes))
fmt.Fprintf(w, "Data Uploaded\t%s\n", pretty.Size(datumInfo.Stats.UploadBytes))
totalTime := client.GetDatumTotalTime(datumInfo.Stats).String()
fmt.Fprintf(w, "Total Time\t%s\n", totalTime)
var downloadTime string
dl, err := types.DurationFromProto(datumInfo.Stats.DownloadTime)
if err != nil {
downloadTime = err.Error()
}
downloadTime = dl.String()
fmt.Fprintf(w, "Download Time\t%s\n", downloadTime)
var procTime string
proc, err := types.DurationFromProto(datumInfo.Stats.ProcessTime)
if err != nil {
procTime = err.Error()
}
procTime = proc.String()
fmt.Fprintf(w, "Process Time\t%s\n", procTime)
var uploadTime string
ul, err := types.DurationFromProto(datumInfo.Stats.UploadTime)
if err != nil {
uploadTime = err.Error()
}
uploadTime = ul.String()
fmt.Fprintf(w, "Upload Time\t%s\n", uploadTime)
fmt.Fprintf(w, "PFS State:\n")
tw := ansiterm.NewTabWriter(w, 10, 1, 3, ' ', 0)
PrintFileHeader(tw)
PrintFile(tw, datumInfo.PfsState)
tw.Flush()
fmt.Fprintf(w, "Inputs:\n")
tw = ansiterm.NewTabWriter(w, 10, 1, 3, ' ', 0)
PrintFileHeader(tw)
for _, d := range datumInfo.Data {
PrintFile(tw, d.File)
}
tw.Flush()
}
|
go
|
func PrintDetailedDatumInfo(w io.Writer, datumInfo *ppsclient.DatumInfo) {
fmt.Fprintf(w, "ID\t%s\n", datumInfo.Datum.ID)
fmt.Fprintf(w, "Job ID\t%s\n", datumInfo.Datum.Job.ID)
fmt.Fprintf(w, "State\t%s\n", datumInfo.State)
fmt.Fprintf(w, "Data Downloaded\t%s\n", pretty.Size(datumInfo.Stats.DownloadBytes))
fmt.Fprintf(w, "Data Uploaded\t%s\n", pretty.Size(datumInfo.Stats.UploadBytes))
totalTime := client.GetDatumTotalTime(datumInfo.Stats).String()
fmt.Fprintf(w, "Total Time\t%s\n", totalTime)
var downloadTime string
dl, err := types.DurationFromProto(datumInfo.Stats.DownloadTime)
if err != nil {
downloadTime = err.Error()
}
downloadTime = dl.String()
fmt.Fprintf(w, "Download Time\t%s\n", downloadTime)
var procTime string
proc, err := types.DurationFromProto(datumInfo.Stats.ProcessTime)
if err != nil {
procTime = err.Error()
}
procTime = proc.String()
fmt.Fprintf(w, "Process Time\t%s\n", procTime)
var uploadTime string
ul, err := types.DurationFromProto(datumInfo.Stats.UploadTime)
if err != nil {
uploadTime = err.Error()
}
uploadTime = ul.String()
fmt.Fprintf(w, "Upload Time\t%s\n", uploadTime)
fmt.Fprintf(w, "PFS State:\n")
tw := ansiterm.NewTabWriter(w, 10, 1, 3, ' ', 0)
PrintFileHeader(tw)
PrintFile(tw, datumInfo.PfsState)
tw.Flush()
fmt.Fprintf(w, "Inputs:\n")
tw = ansiterm.NewTabWriter(w, 10, 1, 3, ' ', 0)
PrintFileHeader(tw)
for _, d := range datumInfo.Data {
PrintFile(tw, d.File)
}
tw.Flush()
}
|
[
"func",
"PrintDetailedDatumInfo",
"(",
"w",
"io",
".",
"Writer",
",",
"datumInfo",
"*",
"ppsclient",
".",
"DatumInfo",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"ID\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"datumInfo",
".",
"Datum",
".",
"ID",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"Job ID\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"datumInfo",
".",
"Datum",
".",
"Job",
".",
"ID",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"State\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"datumInfo",
".",
"State",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"Data Downloaded\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"pretty",
".",
"Size",
"(",
"datumInfo",
".",
"Stats",
".",
"DownloadBytes",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"Data Uploaded\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"pretty",
".",
"Size",
"(",
"datumInfo",
".",
"Stats",
".",
"UploadBytes",
")",
"\n",
"totalTime",
":=",
"client",
".",
"GetDatumTotalTime",
"(",
"datumInfo",
".",
"Stats",
")",
".",
"String",
"(",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"Total Time\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"totalTime",
"\n",
"var",
"downloadTime",
"string",
"\n",
"dl",
",",
"err",
":=",
"types",
".",
"DurationFromProto",
"(",
"datumInfo",
".",
"Stats",
".",
"DownloadTime",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"downloadTime",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"downloadTime",
"=",
"dl",
".",
"String",
"(",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"Download Time\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"downloadTime",
"\n",
"var",
"procTime",
"string",
"\n",
"proc",
",",
"err",
":=",
"types",
".",
"DurationFromProto",
"(",
"datumInfo",
".",
"Stats",
".",
"ProcessTime",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"procTime",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"procTime",
"=",
"proc",
".",
"String",
"(",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"Process Time\\t%s\\n\"",
",",
"\\t",
")",
"\n",
"\\n",
"\n",
"}"
] |
// PrintDetailedDatumInfo pretty-prints detailed info about a datum
|
[
"PrintDetailedDatumInfo",
"pretty",
"-",
"prints",
"detailed",
"info",
"about",
"a",
"datum"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L255-L301
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
PrintFile
|
func PrintFile(w io.Writer, file *pfsclient.File) {
fmt.Fprintf(w, " %s\t%s\t%s\t\n", file.Commit.Repo.Name, file.Commit.ID, file.Path)
}
|
go
|
func PrintFile(w io.Writer, file *pfsclient.File) {
fmt.Fprintf(w, " %s\t%s\t%s\t\n", file.Commit.Repo.Name, file.Commit.ID, file.Path)
}
|
[
"func",
"PrintFile",
"(",
"w",
"io",
".",
"Writer",
",",
"file",
"*",
"pfsclient",
".",
"File",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\" %s\\t%s\\t%s\\t\\n\"",
",",
"\\t",
",",
"\\t",
",",
"\\t",
")",
"\n",
"}"
] |
// PrintFile values for a pfs file.
|
[
"PrintFile",
"values",
"for",
"a",
"pfs",
"file",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L309-L311
|
test
|
pachyderm/pachyderm
|
src/server/pps/pretty/pretty.go
|
ShorthandInput
|
func ShorthandInput(input *ppsclient.Input) string {
switch {
case input == nil:
return "none"
case input.Pfs != nil:
return fmt.Sprintf("%s:%s", input.Pfs.Repo, input.Pfs.Glob)
case input.Cross != nil:
var subInput []string
for _, input := range input.Cross {
subInput = append(subInput, ShorthandInput(input))
}
return "(" + strings.Join(subInput, " ⨯ ") + ")"
case input.Union != nil:
var subInput []string
for _, input := range input.Union {
subInput = append(subInput, ShorthandInput(input))
}
return "(" + strings.Join(subInput, " ∪ ") + ")"
case input.Cron != nil:
return fmt.Sprintf("%s:%s", input.Cron.Name, input.Cron.Spec)
}
return ""
}
|
go
|
func ShorthandInput(input *ppsclient.Input) string {
switch {
case input == nil:
return "none"
case input.Pfs != nil:
return fmt.Sprintf("%s:%s", input.Pfs.Repo, input.Pfs.Glob)
case input.Cross != nil:
var subInput []string
for _, input := range input.Cross {
subInput = append(subInput, ShorthandInput(input))
}
return "(" + strings.Join(subInput, " ⨯ ") + ")"
case input.Union != nil:
var subInput []string
for _, input := range input.Union {
subInput = append(subInput, ShorthandInput(input))
}
return "(" + strings.Join(subInput, " ∪ ") + ")"
case input.Cron != nil:
return fmt.Sprintf("%s:%s", input.Cron.Name, input.Cron.Spec)
}
return ""
}
|
[
"func",
"ShorthandInput",
"(",
"input",
"*",
"ppsclient",
".",
"Input",
")",
"string",
"{",
"switch",
"{",
"case",
"input",
"==",
"nil",
":",
"return",
"\"none\"",
"\n",
"case",
"input",
".",
"Pfs",
"!=",
"nil",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s:%s\"",
",",
"input",
".",
"Pfs",
".",
"Repo",
",",
"input",
".",
"Pfs",
".",
"Glob",
")",
"\n",
"case",
"input",
".",
"Cross",
"!=",
"nil",
":",
"var",
"subInput",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"input",
":=",
"range",
"input",
".",
"Cross",
"{",
"subInput",
"=",
"append",
"(",
"subInput",
",",
"ShorthandInput",
"(",
"input",
")",
")",
"\n",
"}",
"\n",
"return",
"\"(\"",
"+",
"strings",
".",
"Join",
"(",
"subInput",
",",
"\" ⨯ \") ",
" ",
"+",
"\"",
"\n",
"\"",
"case",
"input",
".",
"Union",
"!=",
"nil",
":",
"var",
"subInput",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"input",
":=",
"range",
"input",
".",
"Union",
"{",
"subInput",
"=",
"append",
"(",
"subInput",
",",
"ShorthandInput",
"(",
"input",
")",
")",
"\n",
"}",
"\n",
"return",
"\"(\"",
"+",
"strings",
".",
"Join",
"(",
"subInput",
",",
"\" ∪ \") ",
" ",
"+",
"\"",
"\n",
"}",
"\n",
"\"",
"\n",
"}"
] |
// ShorthandInput renders a pps.Input as a short, readable string
|
[
"ShorthandInput",
"renders",
"a",
"pps",
".",
"Input",
"as",
"a",
"short",
"readable",
"string"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L414-L436
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/amazon_client.go
|
Retrieve
|
func (v *vaultCredentialsProvider) Retrieve() (credentials.Value, error) {
var emptyCreds, result credentials.Value // result
// retrieve AWS creds from vault
vaultSecret, err := v.vaultClient.Logical().Read(path.Join("aws", "creds", v.vaultRole))
if err != nil {
return emptyCreds, fmt.Errorf("could not retrieve creds from vault: %v", err)
}
accessKeyIface, accessKeyOk := vaultSecret.Data["access_key"]
awsSecretIface, awsSecretOk := vaultSecret.Data["secret_key"]
if !accessKeyOk || !awsSecretOk {
return emptyCreds, fmt.Errorf("aws creds not present in vault response")
}
// Convert access key & secret in response to strings
result.AccessKeyID, accessKeyOk = accessKeyIface.(string)
result.SecretAccessKey, awsSecretOk = awsSecretIface.(string)
if !accessKeyOk || !awsSecretOk {
return emptyCreds, fmt.Errorf("aws creds in vault response were not both strings (%T and %T)", accessKeyIface, awsSecretIface)
}
// update the lease values in 'v', and spawn a goroutine to renew the lease
v.updateLease(vaultSecret)
go func() {
for {
// renew at half the lease duration or one day, whichever is greater
// (lease must expire eventually)
renewInterval := v.getLeaseDuration()
if renewInterval.Seconds() < oneDayInSeconds {
renewInterval = oneDayInSeconds * time.Second
}
// Wait until 'renewInterval' has elapsed, then renew the lease
time.Sleep(renewInterval)
backoff.RetryNotify(func() error {
// every two days, renew the lease for this node's AWS credentials
vaultSecret, err := v.vaultClient.Sys().Renew(v.leaseID, twoDaysInSeconds)
if err != nil {
return err
}
v.updateLease(vaultSecret)
return nil
}, backoff.NewExponentialBackOff(), func(err error, _ time.Duration) error {
log.Errorf("could not renew vault lease: %v", err)
return nil
})
}
}()
// Per https://www.vaultproject.io/docs/secrets/aws/index.html#usage, wait
// until token is usable
time.Sleep(10 * time.Second)
return result, nil
}
|
go
|
func (v *vaultCredentialsProvider) Retrieve() (credentials.Value, error) {
var emptyCreds, result credentials.Value // result
// retrieve AWS creds from vault
vaultSecret, err := v.vaultClient.Logical().Read(path.Join("aws", "creds", v.vaultRole))
if err != nil {
return emptyCreds, fmt.Errorf("could not retrieve creds from vault: %v", err)
}
accessKeyIface, accessKeyOk := vaultSecret.Data["access_key"]
awsSecretIface, awsSecretOk := vaultSecret.Data["secret_key"]
if !accessKeyOk || !awsSecretOk {
return emptyCreds, fmt.Errorf("aws creds not present in vault response")
}
// Convert access key & secret in response to strings
result.AccessKeyID, accessKeyOk = accessKeyIface.(string)
result.SecretAccessKey, awsSecretOk = awsSecretIface.(string)
if !accessKeyOk || !awsSecretOk {
return emptyCreds, fmt.Errorf("aws creds in vault response were not both strings (%T and %T)", accessKeyIface, awsSecretIface)
}
// update the lease values in 'v', and spawn a goroutine to renew the lease
v.updateLease(vaultSecret)
go func() {
for {
// renew at half the lease duration or one day, whichever is greater
// (lease must expire eventually)
renewInterval := v.getLeaseDuration()
if renewInterval.Seconds() < oneDayInSeconds {
renewInterval = oneDayInSeconds * time.Second
}
// Wait until 'renewInterval' has elapsed, then renew the lease
time.Sleep(renewInterval)
backoff.RetryNotify(func() error {
// every two days, renew the lease for this node's AWS credentials
vaultSecret, err := v.vaultClient.Sys().Renew(v.leaseID, twoDaysInSeconds)
if err != nil {
return err
}
v.updateLease(vaultSecret)
return nil
}, backoff.NewExponentialBackOff(), func(err error, _ time.Duration) error {
log.Errorf("could not renew vault lease: %v", err)
return nil
})
}
}()
// Per https://www.vaultproject.io/docs/secrets/aws/index.html#usage, wait
// until token is usable
time.Sleep(10 * time.Second)
return result, nil
}
|
[
"func",
"(",
"v",
"*",
"vaultCredentialsProvider",
")",
"Retrieve",
"(",
")",
"(",
"credentials",
".",
"Value",
",",
"error",
")",
"{",
"var",
"emptyCreds",
",",
"result",
"credentials",
".",
"Value",
"\n",
"vaultSecret",
",",
"err",
":=",
"v",
".",
"vaultClient",
".",
"Logical",
"(",
")",
".",
"Read",
"(",
"path",
".",
"Join",
"(",
"\"aws\"",
",",
"\"creds\"",
",",
"v",
".",
"vaultRole",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"emptyCreds",
",",
"fmt",
".",
"Errorf",
"(",
"\"could not retrieve creds from vault: %v\"",
",",
"err",
")",
"\n",
"}",
"\n",
"accessKeyIface",
",",
"accessKeyOk",
":=",
"vaultSecret",
".",
"Data",
"[",
"\"access_key\"",
"]",
"\n",
"awsSecretIface",
",",
"awsSecretOk",
":=",
"vaultSecret",
".",
"Data",
"[",
"\"secret_key\"",
"]",
"\n",
"if",
"!",
"accessKeyOk",
"||",
"!",
"awsSecretOk",
"{",
"return",
"emptyCreds",
",",
"fmt",
".",
"Errorf",
"(",
"\"aws creds not present in vault response\"",
")",
"\n",
"}",
"\n",
"result",
".",
"AccessKeyID",
",",
"accessKeyOk",
"=",
"accessKeyIface",
".",
"(",
"string",
")",
"\n",
"result",
".",
"SecretAccessKey",
",",
"awsSecretOk",
"=",
"awsSecretIface",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"accessKeyOk",
"||",
"!",
"awsSecretOk",
"{",
"return",
"emptyCreds",
",",
"fmt",
".",
"Errorf",
"(",
"\"aws creds in vault response were not both strings (%T and %T)\"",
",",
"accessKeyIface",
",",
"awsSecretIface",
")",
"\n",
"}",
"\n",
"v",
".",
"updateLease",
"(",
"vaultSecret",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"renewInterval",
":=",
"v",
".",
"getLeaseDuration",
"(",
")",
"\n",
"if",
"renewInterval",
".",
"Seconds",
"(",
")",
"<",
"oneDayInSeconds",
"{",
"renewInterval",
"=",
"oneDayInSeconds",
"*",
"time",
".",
"Second",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"renewInterval",
")",
"\n",
"backoff",
".",
"RetryNotify",
"(",
"func",
"(",
")",
"error",
"{",
"vaultSecret",
",",
"err",
":=",
"v",
".",
"vaultClient",
".",
"Sys",
"(",
")",
".",
"Renew",
"(",
"v",
".",
"leaseID",
",",
"twoDaysInSeconds",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"v",
".",
"updateLease",
"(",
"vaultSecret",
")",
"\n",
"return",
"nil",
"\n",
"}",
",",
"backoff",
".",
"NewExponentialBackOff",
"(",
")",
",",
"func",
"(",
"err",
"error",
",",
"_",
"time",
".",
"Duration",
")",
"error",
"{",
"log",
".",
"Errorf",
"(",
"\"could not renew vault lease: %v\"",
",",
"err",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"time",
".",
"Sleep",
"(",
"10",
"*",
"time",
".",
"Second",
")",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] |
// Retrieve returns nil if it successfully retrieved the value. Error is
// returned if the value were not obtainable, or empty.
|
[
"Retrieve",
"returns",
"nil",
"if",
"it",
"successfully",
"retrieved",
"the",
"value",
".",
"Error",
"is",
"returned",
"if",
"the",
"value",
"were",
"not",
"obtainable",
"or",
"empty",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/amazon_client.go#L90-L143
|
test
|
pachyderm/pachyderm
|
src/server/pkg/obj/amazon_client.go
|
IsExpired
|
func (v *vaultCredentialsProvider) IsExpired() bool {
v.leaseMu.Lock()
defer v.leaseMu.Unlock()
return time.Now().After(v.leaseLastRenew.Add(v.leaseDuration))
}
|
go
|
func (v *vaultCredentialsProvider) IsExpired() bool {
v.leaseMu.Lock()
defer v.leaseMu.Unlock()
return time.Now().After(v.leaseLastRenew.Add(v.leaseDuration))
}
|
[
"func",
"(",
"v",
"*",
"vaultCredentialsProvider",
")",
"IsExpired",
"(",
")",
"bool",
"{",
"v",
".",
"leaseMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"v",
".",
"leaseMu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"time",
".",
"Now",
"(",
")",
".",
"After",
"(",
"v",
".",
"leaseLastRenew",
".",
"Add",
"(",
"v",
".",
"leaseDuration",
")",
")",
"\n",
"}"
] |
// IsExpired returns if the credentials are no longer valid, and need to be
// retrieved.
|
[
"IsExpired",
"returns",
"if",
"the",
"credentials",
"are",
"no",
"longer",
"valid",
"and",
"need",
"to",
"be",
"retrieved",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/amazon_client.go#L147-L151
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
NewBranch
|
func NewBranch(repoName string, branchName string) *pfs.Branch {
return &pfs.Branch{
Repo: NewRepo(repoName),
Name: branchName,
}
}
|
go
|
func NewBranch(repoName string, branchName string) *pfs.Branch {
return &pfs.Branch{
Repo: NewRepo(repoName),
Name: branchName,
}
}
|
[
"func",
"NewBranch",
"(",
"repoName",
"string",
",",
"branchName",
"string",
")",
"*",
"pfs",
".",
"Branch",
"{",
"return",
"&",
"pfs",
".",
"Branch",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"Name",
":",
"branchName",
",",
"}",
"\n",
"}"
] |
// NewBranch creates a pfs.Branch
|
[
"NewBranch",
"creates",
"a",
"pfs",
".",
"Branch"
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L22-L27
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
NewCommit
|
func NewCommit(repoName string, commitID string) *pfs.Commit {
return &pfs.Commit{
Repo: NewRepo(repoName),
ID: commitID,
}
}
|
go
|
func NewCommit(repoName string, commitID string) *pfs.Commit {
return &pfs.Commit{
Repo: NewRepo(repoName),
ID: commitID,
}
}
|
[
"func",
"NewCommit",
"(",
"repoName",
"string",
",",
"commitID",
"string",
")",
"*",
"pfs",
".",
"Commit",
"{",
"return",
"&",
"pfs",
".",
"Commit",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"ID",
":",
"commitID",
",",
"}",
"\n",
"}"
] |
// NewCommit creates a pfs.Commit.
|
[
"NewCommit",
"creates",
"a",
"pfs",
".",
"Commit",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L30-L35
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
NewCommitProvenance
|
func NewCommitProvenance(repoName string, branchName string, commitID string) *pfs.CommitProvenance {
return &pfs.CommitProvenance{
Commit: NewCommit(repoName, commitID),
Branch: NewBranch(repoName, branchName),
}
}
|
go
|
func NewCommitProvenance(repoName string, branchName string, commitID string) *pfs.CommitProvenance {
return &pfs.CommitProvenance{
Commit: NewCommit(repoName, commitID),
Branch: NewBranch(repoName, branchName),
}
}
|
[
"func",
"NewCommitProvenance",
"(",
"repoName",
"string",
",",
"branchName",
"string",
",",
"commitID",
"string",
")",
"*",
"pfs",
".",
"CommitProvenance",
"{",
"return",
"&",
"pfs",
".",
"CommitProvenance",
"{",
"Commit",
":",
"NewCommit",
"(",
"repoName",
",",
"commitID",
")",
",",
"Branch",
":",
"NewBranch",
"(",
"repoName",
",",
"branchName",
")",
",",
"}",
"\n",
"}"
] |
// NewCommitProvenance creates a pfs.CommitProvenance.
|
[
"NewCommitProvenance",
"creates",
"a",
"pfs",
".",
"CommitProvenance",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L38-L43
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
NewFile
|
func NewFile(repoName string, commitID string, path string) *pfs.File {
return &pfs.File{
Commit: NewCommit(repoName, commitID),
Path: path,
}
}
|
go
|
func NewFile(repoName string, commitID string, path string) *pfs.File {
return &pfs.File{
Commit: NewCommit(repoName, commitID),
Path: path,
}
}
|
[
"func",
"NewFile",
"(",
"repoName",
"string",
",",
"commitID",
"string",
",",
"path",
"string",
")",
"*",
"pfs",
".",
"File",
"{",
"return",
"&",
"pfs",
".",
"File",
"{",
"Commit",
":",
"NewCommit",
"(",
"repoName",
",",
"commitID",
")",
",",
"Path",
":",
"path",
",",
"}",
"\n",
"}"
] |
// NewFile creates a pfs.File.
|
[
"NewFile",
"creates",
"a",
"pfs",
".",
"File",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L46-L51
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
CreateRepo
|
func (c APIClient) CreateRepo(repoName string) error {
_, err := c.PfsAPIClient.CreateRepo(
c.Ctx(),
&pfs.CreateRepoRequest{
Repo: NewRepo(repoName),
},
)
return grpcutil.ScrubGRPC(err)
}
|
go
|
func (c APIClient) CreateRepo(repoName string) error {
_, err := c.PfsAPIClient.CreateRepo(
c.Ctx(),
&pfs.CreateRepoRequest{
Repo: NewRepo(repoName),
},
)
return grpcutil.ScrubGRPC(err)
}
|
[
"func",
"(",
"c",
"APIClient",
")",
"CreateRepo",
"(",
"repoName",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"CreateRepo",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"CreateRepoRequest",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"}",
",",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}"
] |
// CreateRepo creates a new Repo object in pfs with the given name. Repos are
// the top level data object in pfs and should be used to store data of a
// similar type. For example rather than having a single Repo for an entire
// project you might have separate Repos for logs, metrics, database dumps etc.
|
[
"CreateRepo",
"creates",
"a",
"new",
"Repo",
"object",
"in",
"pfs",
"with",
"the",
"given",
"name",
".",
"Repos",
"are",
"the",
"top",
"level",
"data",
"object",
"in",
"pfs",
"and",
"should",
"be",
"used",
"to",
"store",
"data",
"of",
"a",
"similar",
"type",
".",
"For",
"example",
"rather",
"than",
"having",
"a",
"single",
"Repo",
"for",
"an",
"entire",
"project",
"you",
"might",
"have",
"separate",
"Repos",
"for",
"logs",
"metrics",
"database",
"dumps",
"etc",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L78-L86
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
InspectRepo
|
func (c APIClient) InspectRepo(repoName string) (*pfs.RepoInfo, error) {
resp, err := c.PfsAPIClient.InspectRepo(
c.Ctx(),
&pfs.InspectRepoRequest{
Repo: NewRepo(repoName),
},
)
if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
return resp, nil
}
|
go
|
func (c APIClient) InspectRepo(repoName string) (*pfs.RepoInfo, error) {
resp, err := c.PfsAPIClient.InspectRepo(
c.Ctx(),
&pfs.InspectRepoRequest{
Repo: NewRepo(repoName),
},
)
if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
return resp, nil
}
|
[
"func",
"(",
"c",
"APIClient",
")",
"InspectRepo",
"(",
"repoName",
"string",
")",
"(",
"*",
"pfs",
".",
"RepoInfo",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"InspectRepo",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"InspectRepoRequest",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"}",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"resp",
",",
"nil",
"\n",
"}"
] |
// InspectRepo returns info about a specific Repo.
|
[
"InspectRepo",
"returns",
"info",
"about",
"a",
"specific",
"Repo",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L89-L100
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
ListRepo
|
func (c APIClient) ListRepo() ([]*pfs.RepoInfo, error) {
request := &pfs.ListRepoRequest{}
repoInfos, err := c.PfsAPIClient.ListRepo(
c.Ctx(),
request,
)
if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
return repoInfos.RepoInfo, nil
}
|
go
|
func (c APIClient) ListRepo() ([]*pfs.RepoInfo, error) {
request := &pfs.ListRepoRequest{}
repoInfos, err := c.PfsAPIClient.ListRepo(
c.Ctx(),
request,
)
if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
return repoInfos.RepoInfo, nil
}
|
[
"func",
"(",
"c",
"APIClient",
")",
"ListRepo",
"(",
")",
"(",
"[",
"]",
"*",
"pfs",
".",
"RepoInfo",
",",
"error",
")",
"{",
"request",
":=",
"&",
"pfs",
".",
"ListRepoRequest",
"{",
"}",
"\n",
"repoInfos",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"ListRepo",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"request",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"repoInfos",
".",
"RepoInfo",
",",
"nil",
"\n",
"}"
] |
// ListRepo returns info about all Repos.
// provenance specifies a set of provenance repos, only repos which have ALL of
// the specified repos as provenance will be returned unless provenance is nil
// in which case it is ignored.
|
[
"ListRepo",
"returns",
"info",
"about",
"all",
"Repos",
".",
"provenance",
"specifies",
"a",
"set",
"of",
"provenance",
"repos",
"only",
"repos",
"which",
"have",
"ALL",
"of",
"the",
"specified",
"repos",
"as",
"provenance",
"will",
"be",
"returned",
"unless",
"provenance",
"is",
"nil",
"in",
"which",
"case",
"it",
"is",
"ignored",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L106-L116
|
test
|
pachyderm/pachyderm
|
src/client/pfs.go
|
DeleteRepo
|
func (c APIClient) DeleteRepo(repoName string, force bool) error {
_, err := c.PfsAPIClient.DeleteRepo(
c.Ctx(),
&pfs.DeleteRepoRequest{
Repo: NewRepo(repoName),
Force: force,
},
)
return grpcutil.ScrubGRPC(err)
}
|
go
|
func (c APIClient) DeleteRepo(repoName string, force bool) error {
_, err := c.PfsAPIClient.DeleteRepo(
c.Ctx(),
&pfs.DeleteRepoRequest{
Repo: NewRepo(repoName),
Force: force,
},
)
return grpcutil.ScrubGRPC(err)
}
|
[
"func",
"(",
"c",
"APIClient",
")",
"DeleteRepo",
"(",
"repoName",
"string",
",",
"force",
"bool",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"DeleteRepo",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"DeleteRepoRequest",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"Force",
":",
"force",
",",
"}",
",",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}"
] |
// DeleteRepo deletes a repo and reclaims the storage space it was using. Note
// that as of 1.0 we do not reclaim the blocks that the Repo was referencing,
// this is because they may also be referenced by other Repos and deleting them
// would make those Repos inaccessible. This will be resolved in later
// versions.
// If "force" is set to true, the repo will be removed regardless of errors.
// This argument should be used with care.
|
[
"DeleteRepo",
"deletes",
"a",
"repo",
"and",
"reclaims",
"the",
"storage",
"space",
"it",
"was",
"using",
".",
"Note",
"that",
"as",
"of",
"1",
".",
"0",
"we",
"do",
"not",
"reclaim",
"the",
"blocks",
"that",
"the",
"Repo",
"was",
"referencing",
"this",
"is",
"because",
"they",
"may",
"also",
"be",
"referenced",
"by",
"other",
"Repos",
"and",
"deleting",
"them",
"would",
"make",
"those",
"Repos",
"inaccessible",
".",
"This",
"will",
"be",
"resolved",
"in",
"later",
"versions",
".",
"If",
"force",
"is",
"set",
"to",
"true",
"the",
"repo",
"will",
"be",
"removed",
"regardless",
"of",
"errors",
".",
"This",
"argument",
"should",
"be",
"used",
"with",
"care",
"."
] |
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L125-L134
|
test
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.