forked from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·92 lines (72 loc) · 1.74 KB
/
build.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
set -e
set -o pipefail
instruction()
{
echo -e "usage: ./build.sh command <params> "
echo -e
echo -e "Available commands:"
echo -e
echo -e "build"
echo -e
echo -e "release"
echo -e
}
# Parse options in format --arg value.
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# There only one positional arg that is the command:
COMMAND=$1
if [ $# -eq 0 ]; then
instruction
exit 1
fi
# Run commands
case $COMMAND in
build)
nbdev_build_lib
;;
pair-notebooks)
jupytext --set-formats ipynb,py:light src/*.ipynb
;;
sync-notebooks)
jupytext --sync src/*.py
;;
run)
if [ $ETL_NAME ]; then
ETL_NAME_ARG="--name $ETL_NAME"
fi
nbdev_build_lib
python -m {lib_name} $ETL_NAME_ARG
;;
release)
AWS_ACCOUNT=$(aws sts get-caller-identity --query "Account" --output text)
CODEARTIFACT_DOMAIN=taidy
CODEARTIFACT_REPOSITORY=taidy
# clean mbit_etl folder
rm -rf {lib_name}
nbdev_build_lib
rm -rf dist
python setup.py sdist bdist_wheel
export TWINE_USERNAME=aws
export TWINE_PASSWORD=`aws codeartifact get-authorization-token --domain ${CODEARTIFACT_DOMAIN} --domain-owner ${AWS_ACCOUNT} --query authorizationToken --output text`
export TWINE_REPOSITORY_URL=https://${CODEARTIFACT_DOMAIN}-${AWS_ACCOUNT}.d.codeartifact.eu-west-1.amazonaws.com/pypi/${CODEARTIFACT_REPOSITORY}/
twine upload --repository codeartifact dist/*
;;
*)
echo -e "Unrecognized Command $COMMAND"
echo -e
instruction
exit 1
;;
esac