-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: "dependencies" support in Application spec
Signed-off-by: aavarghese <[email protected]>
- Loading branch information
1 parent
5622d6d
commit 3dd442f
Showing
25 changed files
with
320 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//go:build full || deploy | ||
|
||
package subcommands | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/cmd/options" | ||
"lunchpail.io/cmd/subcommands/dependencies" | ||
) | ||
|
||
func newDependenciesCmd() *cobra.Command { | ||
var cmd = &cobra.Command{ | ||
Use: "dependencies", | ||
Short: "Commands for installing pre-requisites", | ||
Long: "Commands for installing pre-requisites", | ||
} | ||
|
||
opts, err := options.RestoreCompilationOptions() | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
options.AddTargetOptionsTo(cmd, &opts) | ||
options.AddLogOptionsTo(cmd, &opts) | ||
|
||
cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
//Todo | ||
return nil | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
func init() { | ||
cmd := newDependenciesCmd() | ||
rootCmd.AddCommand(cmd) | ||
cmd.AddCommand(dependencies.Minio()) | ||
cmd.AddCommand(dependencies.Python()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dependencies | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/pkg/runtime/dependencies" | ||
) | ||
|
||
func Minio() *cobra.Command { | ||
|
||
cmd := &cobra.Command{ | ||
Use: "minio", | ||
Short: "Install minio", | ||
Long: "Install minio", | ||
Args: cobra.MatchAll(cobra.ExactArgs(0), cobra.OnlyValidArgs), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return dependencies.InstallMinio(context.Background()) | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dependencies | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/pkg/runtime/dependencies" | ||
) | ||
|
||
func Python() *cobra.Command { | ||
|
||
cmd := &cobra.Command{ | ||
Use: "python", | ||
Short: "Install conda/python environment", | ||
Long: "Install conda/python environment", | ||
Args: cobra.MatchAll(cobra.ExactArgs(0), cobra.OnlyValidArgs), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return dependencies.InstallPython(context.Background()) | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dependencies | ||
|
||
import ( | ||
"errors" | ||
"os/exec" | ||
) | ||
|
||
func DepsMinio() error { | ||
if err := setenvForMinio(); err != nil { | ||
return err | ||
} | ||
|
||
if _, err := exec.LookPath("minio"); err != nil { | ||
if errors.Is(err, exec.ErrNotFound) { | ||
return installMinio() | ||
} else if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dependencies | ||
|
||
import ( | ||
"errors" | ||
"os/exec" | ||
) | ||
|
||
func DepsPython() error { | ||
if _, err := exec.LookPath("python"); err != nil { | ||
if errors.Is(err, exec.ErrNotFound) { | ||
return installPython() | ||
} else if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dependencies | ||
|
||
import ( | ||
"context" | ||
|
||
"lunchpail.io/pkg/be/dependencies" | ||
) | ||
|
||
func InstallMinio(ctx context.Context) error { | ||
return dependencies.DepsMinio() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dependencies | ||
|
||
import ( | ||
"context" | ||
|
||
"lunchpail.io/pkg/be/dependencies" | ||
) | ||
|
||
func InstallPython(ctx context.Context) error { | ||
return dependencies.DepsPython() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# test7-python | ||
|
||
This is a variant of python-basic, but using `dependencies` Application support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
SCRIPTDIR=$(cd $(dirname "$0") && pwd) | ||
|
||
export NAMESPACE=$1 | ||
|
||
# number of task | ||
N=${2-10} | ||
|
||
# name of s3 bucket in which to store the tasks | ||
BUCKET=${3-test7} | ||
RUN_NAME=$BUCKET | ||
|
||
B=$(mktemp -d)/$BUCKET # bucket path | ||
D=$B/$BUCKET # data path; in this case the bucket name and the folder name are both the run name | ||
mkdir -p $D | ||
echo "Staging to $D" 1>&2 | ||
|
||
for idx in $(seq 1 $N) # for each iteration | ||
do | ||
# if we are doing a test, then make sure to use a | ||
# repeatable name for the task files, so that we know what | ||
# to look for when confirming that the tasks were | ||
# processed by the workers | ||
if [[ -n "$CI" ]] || [[ -n "$RUNNING_LUNCHPAIL_TESTS" ]]; then | ||
id=$idx | ||
else | ||
# otherwise, use a more random name, so that we can | ||
# inject multiple batches of tasks across executions | ||
# of this script | ||
id=$(uuidgen) | ||
fi | ||
|
||
echo "this is task idx=$idx" > $D/task.$id.txt | ||
done | ||
|
||
"$SCRIPTDIR"/../../../tests/bin/add-data.sh $B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPTDIR=$(cd $(dirname "$0") && pwd) | ||
|
||
# make sure these values are compatible with the values in ./settings.sh | ||
NUM_TASKS=6 | ||
|
||
# $1: namespace | ||
|
||
"$SCRIPTDIR"/add-data-to-queue.sh \ | ||
$1 \ | ||
$NUM_TASKS \ | ||
${TEST_NAME-test7} |
Oops, something went wrong.