-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathcopy-remote-ast.sh
More file actions
executable file
·43 lines (32 loc) · 1.77 KB
/
copy-remote-ast.sh
File metadata and controls
executable file
·43 lines (32 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# This script assumes the target Cloud Workspace specified as the command-line argument has the build target.
# To make sure this is the case, run bazel build //Snowpark/ast:ast_proto && bazel build //Snowpark/unparser && bazel run //Snowpark/unparser.
# The bazel build commands will create the proto and unparser.jar files, whereas bazel run will create the run-files directory.
# N.B. The calling environment further requires:
# export MONOREPO_DIR=$TMPDIR
set -euxo pipefail
if [ "$#" -ne 1 ]; then
echo "Wrong number of parameters, usage: ./copy-remote-ast.sh <workspace id>"
exit 1
fi
MONOREPO_DIR=${MONOREPO_DIR:-$TMPDIR}
# To allow this script to run from any subdirectory within snowpark-python, we use git rev-parse.
SNOWPARK_ROOT=$(git rev-parse --show-toplevel)
if [ ! -d "$MONOREPO_DIR" ]; then
echo "MONOREPO_DIR not defined"
exit 1
fi
# Quick way to determine what ~ is on the server, made explicit to avoid confusion.
REMOTE_HOME=$(ssh $1 'echo "$HOME"')
# Run bazel build remotely.
# Adding _deploy to a bazel JVM target builds a fat jar,
# For the unparser this target is //Snowpark/unparser:unparser_deploy.jar.
ssh $1 'cd ~/Snowflake/trunk && bazel build //Snowpark/ast:ast_proto && bazel build //Snowpark/unparser:unparser_deploy.jar'
# (1) Copy over ast.proto file (required by python -x tox -e protoc).
scp $1:"$REMOTE_HOME/Snowflake/trunk/bazel-bin/Snowpark/ast/ast.proto" $SNOWPARK_ROOT/src/snowflake/snowpark/_internal/proto/ast.proto
# (2) Copy over fat unparser_deploy.jar and rename to unparser.jar.
mkdir -p $MONOREPO_DIR/bazel-bin/Snowpark/unparser/
scp $1:$REMOTE_HOME/Snowflake/trunk/bazel-bin/Snowpark/unparser/unparser_deploy.jar $MONOREPO_DIR/bazel-bin/Snowpark/unparser/unparser.jar
pushd $SNOWPARK_ROOT
python -m tox -e protoc
popd