Skip to content

Commit 04c5519

Browse files
committed
feat: ibmcloud be to use local setup rather than k8 kind cluster
Signed-off-by: aavarghese <[email protected]>
1 parent b3f948d commit 04c5519

File tree

38 files changed

+374
-164
lines changed

38 files changed

+374
-164
lines changed

cmd/subcommands/component.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ func init() {
1717
cmd.AddCommand(component.Minio())
1818
cmd.AddCommand(component.Worker())
1919
cmd.AddCommand(component.WorkStealer())
20+
cmd.AddCommand(component.RunLocally())
2021
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package component
2+
3+
import (
4+
"context"
5+
6+
"github.com/spf13/cobra"
7+
"lunchpail.io/cmd/options"
8+
"lunchpail.io/pkg/build"
9+
"lunchpail.io/pkg/runtime"
10+
)
11+
12+
type RunLocallyOptions struct {
13+
Component string
14+
LLIR string
15+
build.LogOptions
16+
}
17+
18+
func AddRunLocallyOptions(cmd *cobra.Command) *RunLocallyOptions {
19+
options := RunLocallyOptions{}
20+
cmd.Flags().StringVarP(&options.Component, "component", "", "", "")
21+
cmd.Flags().StringVar(&options.LLIR, "llir", "", "")
22+
cmd.MarkFlagRequired("component")
23+
cmd.MarkFlagRequired("llir")
24+
return &options
25+
}
26+
27+
func RunLocally() *cobra.Command {
28+
cmd := &cobra.Command{
29+
Use: "run-locally",
30+
Short: "Commands for running a component locally",
31+
Long: "Commands for running a component locally",
32+
}
33+
34+
runOpts := AddRunLocallyOptions(cmd)
35+
options.AddLogOptions(cmd)
36+
37+
cmd.RunE = func(cmd *cobra.Command, args []string) error {
38+
return runtime.RunLocally(context.Background(), runOpts.Component, runOpts.LLIR, runOpts.LogOptions)
39+
}
40+
41+
return cmd
42+
}

cmd/subcommands/component/worker/run.go

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package worker
33
import (
44
"context"
55
"fmt"
6+
"time"
67

78
"github.com/spf13/cobra"
89

@@ -64,6 +65,7 @@ func Run() *cobra.Command {
6465
PollingInterval: pollingInterval,
6566
LogOptions: *logOpts,
6667
RunContext: run.ForStep(step).ForPool(poolName).ForWorker(workerName),
68+
WorkerStartTime: time.Now(),
6769
})
6870
}
6971

cmd/subcommands/queue/cat.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func Cat() *cobra.Command {
4141
return err
4242
}
4343

44-
return queue.Qcat(ctx, backend, run, args[0], *opts.Log)
44+
return queue.Qcat(ctx, backend, run, args[0], q.Spec{}, *opts.Log)
4545
}
4646

4747
return cmd

cmd/subcommands/queue/drain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func Drain() *cobra.Command {
4343
return err
4444
}
4545

46-
return queue.Drain(ctx, backend, run.ForStep(step), *opts.Log)
46+
return queue.Drain(ctx, backend, run.ForStep(step), q.Spec{}, *opts.Log)
4747
}
4848

4949
return cmd

cmd/subcommands/queue/ls.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func Ls() *cobra.Command {
6060
return err
6161
}
6262

63-
files, errors, err := queue.Ls(ctx, backend, runContext.ForStep(step), path, *opts.Log)
63+
files, errors, err := queue.Ls(ctx, backend, runContext.ForStep(step), path, q.Spec{}, *opts.Log)
6464
if err != nil {
6565
return err
6666
}

cmd/subcommands/queue/upload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Upload() *cobra.Command {
4747
run = rrun.Name
4848
}
4949

50-
return queue.UploadFiles(ctx, backend, q.RunContext{RunName: run}, []upload.Upload{upload.Upload{LocalPath: args[0], Bucket: args[1]}}, *opts.Log)
50+
return queue.UploadFiles(ctx, backend, q.RunContext{RunName: run}, []upload.Upload{upload.Upload{LocalPath: args[0], Bucket: args[1]}}, q.Spec{}, *opts.Log)
5151
}
5252

5353
return cmd

cmd/subcommands/up.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ package subcommands
44

55
import (
66
"context"
7+
"fmt"
78
"os"
9+
"time"
810

911
"github.com/spf13/cobra"
1012

@@ -68,7 +70,12 @@ func newUpCmd() *cobra.Command {
6870
return err
6971
}
7072

71-
_, err = boot.Up(ctx, backend, boot.UpOptions{BuildOptions: *buildOpts, DryRun: dryrunFlag, Watch: watchFlag, WatchUtil: watchFlag, Inputs: args, Executable: os.Args[0], NoRedirect: noRedirect})
73+
upStartTime := time.Now()
74+
_, err = boot.Up(ctx, backend, boot.UpOptions{BuildOptions: *buildOpts, DryRun: dryrunFlag, Watch: watchFlag, WatchUtil: watchFlag, Inputs: args, Executable: os.Args[0], NoRedirect: noRedirect, UpStartTime: time.Now()})
75+
upEndTime := time.Now()
76+
if buildOpts.Verbose() {
77+
fmt.Fprintf(os.Stderr, "METRICS: Took %s for running app e2e\n", util.RelTime(upStartTime, upEndTime))
78+
}
7279
return err
7380
}
7481

demos/data-prep-kit/code/header-cleanser/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ scancode-toolkit-mini
33
# we can probably update to 18+, but we will have to re-generate expected output as pyarrow 18 seems to have resulted in a binary format change
44
pyarrow<17
55

6-
setuptools
6+
setuptools ; platform_system == 'Darwin'

demos/data-prep-kit/language/lang-id/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# hmm, needed for tests at least on macos
22
wheel
3-
setuptools
3+
setuptools ; platform_system == 'Darwin'
44

55
fasttext-wheel==0.9.2
66
langcodes==3.3.0
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pyarrow<17
2-
setuptools
2+
setuptools ; platform_system == 'Darwin'

pkg/be/backend.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Backend interface {
3434
InstanceCount(ctx context.Context, c lunchpail.Component, run queue.RunContext) (int, error)
3535

3636
// Queue properties for a given run, plus ensure access to the endpoint from this client
37-
AccessQueue(ctx context.Context, run queue.RunContext, opts build.LogOptions) (endpoint, accessKeyID, secretAccessKey, bucket string, stop func(), err error)
37+
AccessQueue(ctx context.Context, run queue.RunContext, queue queue.Spec, opts build.LogOptions) (endpoint, accessKeyID, secretAccessKey, bucket string, stop func(), err error)
3838

3939
// Return a streamer
4040
Streamer(ctx context.Context, run queue.RunContext) streamer.Streamer

0 commit comments

Comments
 (0)