Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ check_doc_links: ## Check markdown files for invalid links
.PHONY: check_license
check_license: ## Make sure source files have license header
@git grep -L "SPDX-License-Identifier: Apache-2.0" -- *.py *.yml *.yaml *.sh *.html *.js *.css *.ts *.tsx ':!*.bundle.js' | \
grep . && echo "Missing license headers in files above. Run './hack/add_license_headers.sh'" && exit 1 || \
grep . && echo "Missing license headers in files above. Run './tools/bash/add_license_headers.sh'" && exit 1 || \
echo "$@: OK"
75 changes: 0 additions & 75 deletions api/add_license_headers.sh

This file was deleted.

2 changes: 2 additions & 0 deletions api/client/.swagger-codegen-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

.travis.yml
git_push.sh
requirements.txt
18 changes: 0 additions & 18 deletions api/client/.travis.yml

This file was deleted.

57 changes: 0 additions & 57 deletions api/client/git_push.sh

This file was deleted.

18 changes: 17 additions & 1 deletion api/codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,28 @@ swagger-codegen generate -i swagger/swagger.yaml -l python -o client 2>&1
echo "Generating Python server:"
swagger-codegen generate -i swagger/swagger.yaml -l python-flask -o server 2>&1 | grep -v -E "writing file|/test/" | sed "s|${SCRIPT_DIR}|.|g"

# set interactive mode to enable defining a gsed alias
shopt -s expand_aliases

# we use sed to make in-file text replacements, but sed works differently on macOS and Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
alias gsed="sed -i"
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
alias gsed="sed -i ''"
elif [[ "$OSTYPE" == "cygwin" ]]; then # POSIX compatible emulation for Windows
alias gsed="sed -i"
else
echo "FAILED. OS not compatible with script '${BASH_SOURCE[0]}'"
exit 1
fi
export gsed

# we need to modify the generated controller methods to 'do some magic!' ...
# replace:
# return 'do some magic!'
# with:
# return util.invoke_controller_impl(__name__, locals())
sed -i '' "s/'do some magic\!'/util.invoke_controller_impl()/g" "${SCRIPT_DIR}"/server/swagger_server/controllers/*.py
gsed "s/'do some magic\!'/util.invoke_controller_impl()/g" "${SCRIPT_DIR}"/server/swagger_server/controllers/*.py

# and add the 'magic' utility method to forward the controller invocations ... unless we already did
grep "invoke_controller_impl" "${UTIL_FILE}" -q || cat <<'EOF' >> "${UTIL_FILE}"
Expand Down
11 changes: 6 additions & 5 deletions api/generate_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: Apache-2.0

# define global variables
REPO_URL="git@github.com:machine-learning-exchange/mlx.git"
REPO_URL="https://github.com/machine-learning-exchange/mlx.git"
SCRIPT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
PROJECT_DIR="${TRAVIS_BUILD_DIR:-$(cd "${SCRIPT_DIR%/api}"; pwd)}"
TEMP_DIR="${PROJECT_DIR}/temp"
Expand All @@ -30,14 +30,15 @@ clone_repo_to_tempdir() {
--filter=blob:none #-q
cd "${CLONE_DIR}"
git config core.sparseCheckout true
echo "api/*"> .git/info/sparse-checkout
echo "api/*" > .git/info/sparse-checkout
echo "tools/*" >> .git/info/sparse-checkout
git checkout main #-- api
cd - &> /dev/null
else
echo "Get latest commit from main ..."
cd "${CLONE_DIR}"
git fetch origin # -q
git -c advice.detachedHead=false checkout "${VERSION}" -f -- api #-q
git -c advice.detachedHead=false checkout "${VERSION}" -f -- api tools #-q
cd - &> /dev/null
fi
}
Expand All @@ -49,7 +50,7 @@ generate_reverse_patch_for_undesired_codegen_results() {
echo "========================================================================"
cd "${CLONE_DIR}"
./api/codegen.sh || exit 1
cd api && ./add_license_headers.sh && cd -
./tools/bash/add_license_headers.sh || exit 1
#git diff --output="${TEMP_DIR}/undesired_codegen_results_$(date +"%Y-%m-%d").patch"
git diff -R --output="${TEMP_DIR}/revert_undesired_codegen_results_$(date +"%Y-%m-%d").patch"
#git checkout . # undo local changes
Expand All @@ -63,7 +64,7 @@ generate_code() {
echo "========================================================================"
cd "${PROJECT_DIR}"
./api/codegen.sh || exit 1
cd api && ./add_license_headers.sh && cd -
./tools/bash/add_license_headers.sh || exit 1
}

revert_undesired_codegen_results() {
Expand Down
4 changes: 3 additions & 1 deletion api/server/.swagger-codegen-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ swagger_server/models/protobuf_any.py
swagger_server/util.py
swagger_server/__main__.py

Dockerfile
.dockerignore
.travis.yml
Dockerfile
README.md
git_push.sh
requirements.txt
tox.ini
16 changes: 0 additions & 16 deletions api/server/.travis.yml

This file was deleted.

57 changes: 0 additions & 57 deletions api/server/git_push.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
elif [[ "$OSTYPE" == "cygwin" ]]; then # POSIX compatible emulation for Windows
alias gsed="sed -i"
else
echo "FAILED. OS not compatible with script '/hack/add_license_headers.sh'"
echo "FAILED. OS not compatible with script '${BASH_SOURCE[0]}'"
exit 1
fi
export gsed

hash_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
echo "$1"
gsed '1i\
# Copyright 2021 The MLX Contributors\
#\
Expand All @@ -32,9 +32,9 @@ hash_comment () {
}

slash_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
echo "$1"
gsed '1i\
// Copyright 2021 The MLX Contributors\
//\
Expand All @@ -44,9 +44,9 @@ slash_comment () {
}

css_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
echo "$1"
gsed '1i\
/*\
* Copyright 2021 The MLX Contributors\
Expand All @@ -58,14 +58,14 @@ css_comment () {
}

html_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
echo "$1"
gsed '1i\
<!--\
Copyright 2021 The MLX Contributors\
\
SPDX-License-Identifier: Apache-2.0\
Copyright 2021 The MLX Contributors\
\
SPDX-License-Identifier: Apache-2.0\
-->\
' "$1"
fi
Expand Down