<commit_before># Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash


export PROJECT_ID=$1
export IMAGE=$2
export DOMAIN=$3

SERVICE_ACCOUNT=mixer-robot@$PROJECT_ID.iam.gserviceaccount.com
if [ "$PROJECT_ID" == "datcom-mixer" ]; then
  echo "Set datacommons domain"
  DOMAIN="api.datacommons.org"
fi


cp template_deployment.yaml deployment.yaml
cp template_api_config.yaml api_config.yaml

# Set project id
perl -i -pe's/PROJECT_ID/$ENV{PROJECT_ID}/g' deployment.yaml api_config.yaml

# Set api title
if [ "$PROJECT_ID" == "datcom-mixer" ]; then
  perl -i -pe's/TITLE/Data Commons API/g' api_config.yaml
else
  perl -i -pe's/TITLE/Data Commons API ($ENV{PROJECT_ID})/g' api_config.yaml
fi

# Set docker image
perl -i -pe's/IMAGE/$ENV{IMAGE}/g' deployment.yaml

# Set endpints domain
if [[ $DOMAIN ]]; then
  perl -i -pe's/#_c\|//g' deployment.yaml
  perl -i -pe's/DOMAIN/$ENV{DOMAIN}/g' deployment.yaml
else
  perl -i -pe's/#_d\|//g' deployment.yaml
fi

# Set BT_INSTANCE & BQ dataset
if [ "$PROJECT_ID" == "datcom-mixer-staging" ]; then
  perl -i -pe's/BT_INSTANCE/prophet-cache-staging/g' deployment.yaml
  perl -i -pe's/BQ_DATASET/google.com:datcom-store-dev.dc_v3_staging_clustered/g' deployment.yaml
else 
  perl -i -pe's/BT_INSTANCE/prophet-cache/g' deployment.yaml
  perl -i -pe's/BQ_DATASET/google.com:datcom-store-dev.dc_v3_clustered/g' deployment.yaml
fi

# Set BT table
if [ "$PROJECT_ID" == "datcom-mixer" ]; then
  bt_table_input_file="./prod_bt_table.txt"
else
  bt_table_input_file="./staging_bt_table.txt"
fi
while read -r line; do
  BT_TABLE=$line
done < "$bt_table_input_file"
export BT_TABLE
perl -i -pe's/BT_TABLE/$ENV{BT_TABLE}/g' deployment.yaml
<commit_msg>Update gke to use the same bigtable instance for both prod and staging. (#115)<commit_after># Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash


export PROJECT_ID=$1
export IMAGE=$2
export DOMAIN=$3

SERVICE_ACCOUNT=<EMAIL>@$PROJECT_ID.<EMAIL>
if [ "$PROJECT_ID" == "datcom-mixer" ]; then
  echo "Set datacommons domain"
  DOMAIN="api.datacommons.org"
fi


cp template_deployment.yaml deployment.yaml
cp template_api_config.yaml api_config.yaml

# Set project id
perl -i -pe's/PROJECT_ID/$ENV{PROJECT_ID}/g' deployment.yaml api_config.yaml

# Set api title
if [ "$PROJECT_ID" == "datcom-mixer" ]; then
  perl -i -pe's/TITLE/Data Commons API/g' api_config.yaml
else
  perl -i -pe's/TITLE/Data Commons API ($ENV{PROJECT_ID})/g' api_config.yaml
fi

# Set docker image
perl -i -pe's/IMAGE/$ENV{IMAGE}/g' deployment.yaml

# Set endpints domain
if [[ $DOMAIN ]]; then
  perl -i -pe's/#_c\|//g' deployment.yaml
  perl -i -pe's/DOMAIN/$ENV{DOMAIN}/g' deployment.yaml
else
  perl -i -pe's/#_d\|//g' deployment.yaml
fi

# Set BQ dataset
if [ "$PROJECT_ID" == "datcom-mixer-staging" ]; then
  perl -i -pe's/BQ_DATASET/google.com:datcom-store-dev.dc_v3_staging_clustered/g' deployment.yaml
else 
  perl -i -pe's/BQ_DATASET/google.com:datcom-store-dev.dc_v3_clustered/g' deployment.yaml
fi

# Set BT_INSTANCE, same for prod and staging.
perl -i -pe's/BT_INSTANCE/prophet-cache/g' deployment.yaml

# Set BT table
if [ "$PROJECT_ID" == "datcom-mixer" ]; then
  bt_table_input_file="./prod_bt_table.txt"
else
  bt_table_input_file="./staging_bt_table.txt"
fi
while read -r line; do
  BT_TABLE=$line
done < "$bt_table_input_file"
export BT_TABLE
perl -i -pe's/BT_TABLE/$ENV{BT_TABLE}/g' deployment.yaml

{'fraction_non_alphanumeric': 0.12502815949538185, 'fraction_numerical': 0.00653300292858752, 'mean_word_length': 4.311004784688995, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2923470', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1578, 'n_words': 445}