Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

chore: move samples from python-docs-sample #33

Merged
merged 75 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f865d07
Add samples for DLP API v2beta1 [(#1369)](https://github.com/GoogleCl…
andrewsg Mar 1, 2018
289f38d
Auto-update dependencies. [(#1377)](https://github.com/GoogleCloudPla…
dpebot Mar 5, 2018
403f54a
Update DLP samples for release [(#1415)](https://github.com/GoogleClo…
andrewsg Mar 20, 2018
8ee5d4e
fix DLP region tags, and add @flaky to pub/sub sample tests [(#1418)]…
andrewsg Mar 20, 2018
6c21763
Auto-update dependencies.
dpebot Apr 2, 2018
d06095c
Regenerate the README files and fix the Open in Cloud Shell link for …
Apr 7, 2018
3dd2ff0
Update README for DLP GA [(#1426)](https://github.com/GoogleCloudPlat…
andrewsg Apr 13, 2018
c0c864c
Update READMEs to fix numbering and add git clone [(#1464)](https://g…
frankyn Apr 26, 2018
382fd84
DLP: Add auto_populate_timespan option for create job trigger. [(#154…
micheldavid Jun 27, 2018
9ddf0da
Resolved conflicts.
michaelawyu Jun 29, 2018
29f10f4
Merge branch 'dpebot-repositorygardener' despite flaky dataproc tests
michaelawyu Jun 29, 2018
68b5872
Add DLP code samples for custom info types [(#1524)](https://github.c…
mwdaub Jul 3, 2018
0d2381f
upgrade DLP version and fix tests [(#1784)](https://github.com/Google…
andrewsg Nov 8, 2018
e36f644
Auto-update dependencies. [(#1846)](https://github.com/GoogleCloudPla…
dpebot Nov 20, 2018
ccb070f
Per internal documentation complaint, fix the naming. [(#1933)](https…
realjordanna Jan 25, 2019
33d3152
Add inspect table code sample for DLP and some nit fixes [(#1921)](ht…
ackul Jan 25, 2019
f113c2e
Update DLP redact image code sample region to include mimetype import…
djmailhot Jan 25, 2019
ac8d34e
Update to use new subscribe() syntax [(#1989)](https://github.com/Goo…
engelke Feb 5, 2019
301d4e1
Auto-update dependencies. [(#1980)](https://github.com/GoogleCloudPla…
dpebot Feb 6, 2019
ec2abd1
Convert append -> nargs, so arguments are not additive [(#2191)](http…
maximus12793 Jun 5, 2019
5182a8d
increase test timeout [(#2351)](https://github.com/GoogleCloudPlatfor…
averikitsch Aug 20, 2019
09dccf7
Adds updates including compute [(#2436)](https://github.com/GoogleClo…
gguuss Oct 23, 2019
c38f4e4
Update DLP samples to use dlp_v2 client. [(#2580)](https://github.com…
maximus12793 Dec 6, 2019
27aff06
fix: correct dataset name, use env var for project [(#2621)](https://…
leahecole Feb 10, 2020
5faa642
Remove param to reduce latency (per docs) [(#2853)](https://github.co…
leahecole Feb 12, 2020
3b9f158
chore(deps): update dependency google-cloud-storage to v1.26.0 [(#304…
renovate-bot Mar 9, 2020
c65552b
Fix dlp tests [(#3058)](https://github.com/GoogleCloudPlatform/python…
leahecole Mar 9, 2020
0f3b4da
Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatf…
kurtisvg Apr 2, 2020
74547ae
[dlp] fix: fix periodic builds timeout [(#3420)](https://github.com/G…
Apr 17, 2020
8c01feb
chore(deps): update dependency google-cloud-dlp to v0.14.0 [(#3431)](…
renovate-bot Apr 18, 2020
65073f5
Update dependency google-cloud-datastore to v1.12.0 [(#3296)](https:/…
renovate-bot Apr 21, 2020
e6cb526
Update dependency google-cloud-pubsub to v1.4.2 [(#3340)](https://git…
busunkim96 Apr 22, 2020
5341587
chore(deps): update dependency google-cloud-storage to v1.28.0 [(#326…
renovate-bot Apr 29, 2020
25a1337
[dlp] fix: increase the number of retries for some tests [(#3685)](ht…
May 4, 2020
bfce47e
chore: some lint fixes [(#3744)](https://github.com/GoogleCloudPlatfo…
May 12, 2020
ef233dd
chore(deps): update dependency google-cloud-pubsub to v1.4.3 [(#3725)…
renovate-bot May 13, 2020
ea520da
chore(deps): update dependency google-cloud-dlp to v0.15.0 [(#3780)](…
renovate-bot May 18, 2020
35cfae5
chore(deps): update dependency google-cloud-storage to v1.28.1 [(#378…
renovate-bot May 19, 2020
7ba38a0
chore(deps): update dependency google-cloud-pubsub to v1.5.0 [(#3781)…
renovate-bot May 21, 2020
d57cf44
[dlp] fix: mitigate flakiness [(#3919)](https://github.com/GoogleClou…
Jun 1, 2020
634bd0b
[dlp] testing: fix Pub/Sub notifications [(#3925)](https://github.com…
Jun 3, 2020
ae90593
Add text redaction sample using DLP [(#3964)](https://github.com/Goog…
sethmoo Jun 5, 2020
46b4e8e
testing: start using btlr [(#3959)](https://github.com/GoogleCloudPla…
Jun 9, 2020
ce78cdc
Add code sample for string replacement based deidentification. [(#395…
ackul Jun 9, 2020
f10bfd0
Add custom infoType snippets to DLP samples [(#3991)](https://github.…
sethmoo Jun 9, 2020
4db5b65
Replace GCLOUD_PROJECT with GOOGLE_CLOUD_PROJECT. [(#4022)](https://g…
kurtisvg Jun 9, 2020
5672045
Rename DLP code samples from 'redact' to 'replace' [(#4020)](https://…
jlmwise Jun 9, 2020
e46b609
Add DLP sample for redacting all image text [(#4018)](https://github.…
sethmoo Jun 10, 2020
902a097
Add DLP sample code for inspecting with custom regex detector [(#4031…
lxhfirenking Jun 10, 2020
676457f
Update dependency google-cloud-dlp to v1 [(#4047)](https://github.com…
renovate-bot Jun 10, 2020
2ef334d
Update dependency google-cloud-bigquery to v1.25.0 [(#4024)](https://…
renovate-bot Jun 11, 2020
9d74640
Add code sample and tests for redaction [(#4037)](https://github.com/…
jlmwise Jun 11, 2020
af4ecad
dlp: add inspect string sample, person_name w/ custom hotword certain…
lxhfirenking Jun 12, 2020
fa8478a
Add a simplified inspect string example to DLP code samples [(#4069)]…
jlmwise Jun 12, 2020
4546538
dlp: Add sample for reid w/ fpe using surrogate type and unwrapped se…
lxhfirenking Jun 12, 2020
63fc612
add code sample and test for medical number custom detector with hotw…
lxhfirenking Jun 12, 2020
082989e
Add DLP code sample and test for de-id free text with surrogate [(#40…
lxhfirenking Jun 15, 2020
71c39a2
chore(deps): update dependency google-cloud-storage to v1.29.0 [(#404…
renovate-bot Jun 19, 2020
4d4eae3
Update dependency google-cloud-pubsub to v1.6.0 [(#4039)](https://git…
renovate-bot Jun 20, 2020
1e23c95
[dlp] fix: add retry count to mitigate the flake [(#4152)](https://gi…
Jun 24, 2020
8829d79
chore(deps): update dependency google-cloud-pubsub to v1.6.1 [(#4242)…
renovate-bot Jul 6, 2020
c76cedd
chore(deps): update dependency google-cloud-datastore to v1.13.0 [(#4…
renovate-bot Jul 11, 2020
1227548
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot Jul 12, 2020
923a2d0
chore(deps): update dependency mock to v4 [(#4287)](https://github.co…
renovate-bot Jul 13, 2020
27079ea
chore(deps): update dependency google-cloud-pubsub to v1.7.0 [(#4290)…
renovate-bot Jul 14, 2020
f2f62a8
Update dependency flaky to v3.7.0 [(#4300)](https://github.com/Google…
renovate-bot Jul 16, 2020
20909c5
Update dependency google-cloud-datastore to v1.13.1 [(#4295)](https:/…
renovate-bot Jul 16, 2020
47aaede
chore(deps): update dependency google-cloud-datastore to v1.13.2 [(#4…
renovate-bot Jul 22, 2020
ddbf836
Update dependency google-cloud-storage to v1.30.0
renovate-bot Jul 29, 2020
19c3d15
Update dependency pytest to v6 [(#4390)](https://github.com/GoogleClo…
renovate-bot Aug 1, 2020
fcf9b5c
Resolved merge conflicts in requirements.txt files
engelke Aug 10, 2020
9c6feba
Merge branch 'snippets-samples' into add-snippets-samples
arithmetic1728 Aug 12, 2020
973bcc3
chore: update templates
arithmetic1728 Aug 12, 2020
db0ddb0
chore: update synth.py
arithmetic1728 Aug 12, 2020
de0b830
chore: update project env name
arithmetic1728 Aug 13, 2020
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: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
**/services/**
**/types/**
*_pb2.py

# Standard linting exemptions.
Expand Down
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Code owners file.
# This file controls who is tagged for review for any given pull request.
#
# For syntax help see:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax


/samples/**/*.py @googleapis/python-samples-owners
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
Expand Down Expand Up @@ -45,14 +46,16 @@ pip-log.txt
# Built documentation
docs/_build
bigquery/docs/generated
docs.metadata

# Virtual environment
env/
coverage.xml
sponge_log.xml

# System test environment variables.
system_tests/local_test_setup

# Make sure a generated file isn't accidentally committed.
pylintrc
pylintrc.test
pylintrc.test
8 changes: 7 additions & 1 deletion .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ python3.6 -m pip uninstall --yes --quiet nox-automation
python3.6 -m pip install --upgrade --quiet nox
python3.6 -m nox --version

python3.6 -m nox
# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
python3.6 -m nox -s "${NOX_SESSION:-}"
else
python3.6 -m nox
fi
98 changes: 98 additions & 0 deletions .kokoro/docker/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright 2020 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
#
# http://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.

from ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

# Ensure local Python is preferred over distribution Python.
ENV PATH /usr/local/bin:$PATH

# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
dirmngr \
git \
gpg-agent \
graphviz \
libbz2-dev \
libdb5.3-dev \
libexpat1-dev \
libffi-dev \
liblzma-dev \
libreadline-dev \
libsnappy-dev \
libssl-dev \
libsqlite3-dev \
portaudio19-dev \
redis-server \
software-properties-common \
ssh \
sudo \
tcl \
tcl-dev \
tk \
tk-dev \
uuid-dev \
wget \
zlib1g-dev \
&& add-apt-repository universe \
&& apt-get update \
&& apt-get -y install jq \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/archives/*.deb


COPY fetch_gpg_keys.sh /tmp
# Install the desired versions of Python.
RUN set -ex \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> "${GNUPGHOME}/dirmngr.conf" \
&& /tmp/fetch_gpg_keys.sh \
&& for PYTHON_VERSION in 3.7.8 3.8.5; do \
wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& gpg --batch --verify python-${PYTHON_VERSION}.tar.xz.asc python-${PYTHON_VERSION}.tar.xz \
&& rm -r python-${PYTHON_VERSION}.tar.xz.asc \
&& mkdir -p /usr/src/python-${PYTHON_VERSION} \
&& tar -xJC /usr/src/python-${PYTHON_VERSION} --strip-components=1 -f python-${PYTHON_VERSION}.tar.xz \
&& rm python-${PYTHON_VERSION}.tar.xz \
&& cd /usr/src/python-${PYTHON_VERSION} \
&& ./configure \
--enable-shared \
# This works only on Python 2.7 and throws a warning on every other
# version, but seems otherwise harmless.
--enable-unicode=ucs4 \
--with-system-ffi \
--without-ensurepip \
&& make -j$(nproc) \
&& make install \
&& ldconfig \
; done \
&& rm -rf "${GNUPGHOME}" \
&& rm -rf /usr/src/python* \
&& rm -rf ~/.cache/

RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& python3.7 /tmp/get-pip.py \
&& python3.8 /tmp/get-pip.py \
&& rm /tmp/get-pip.py

CMD ["python3.7"]
45 changes: 45 additions & 0 deletions .kokoro/docker/docs/fetch_gpg_keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# Copyright 2020 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
#
# http://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.

# A script to fetch gpg keys with retry.
# Avoid jinja parsing the file.
#

function retry {
if [[ "${#}" -le 1 ]]; then
echo "Usage: ${0} retry_count commands.."
exit 1
fi
local retries=${1}
local command="${@:2}"
until [[ "${retries}" -le 0 ]]; do
$command && return 0
if [[ $? -ne 0 ]]; then
echo "command failed, retrying"
((retries--))
fi
done
return 1
}

# 3.6.9, 3.7.5 (Ned Deily)
retry 3 gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D

# 3.8.0 (Łukasz Langa)
retry 3 gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
E3FF2839C048B25C084DEBE9B26995E310250568

#
21 changes: 19 additions & 2 deletions .kokoro/docs/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ action {
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-dlp/.kokoro/trampoline.sh"
build_file: "python-dlp/.kokoro/trampoline_v2.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
value: "gcr.io/cloud-devrel-kokoro-resources/python-lib-docs"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
Expand All @@ -28,6 +28,23 @@ env_vars: {
value: "docs-staging"
}

env_vars: {
key: "V2_STAGING_BUCKET"
value: "docs-staging-v2-staging"
}

# It will upload the docker image after successful builds.
env_vars: {
key: "TRAMPOLINE_IMAGE_UPLOAD"
value: "true"
}

# It will always build the docker image.
env_vars: {
key: "TRAMPOLINE_DOCKERFILE"
value: ".kokoro/docker/docs/Dockerfile"
}

# Fetch the token needed for reporting release status to GitHub
before_action {
fetch_keystore {
Expand Down
17 changes: 17 additions & 0 deletions .kokoro/docs/docs-presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "STAGING_BUCKET"
value: "gcloud-python-test"
}

env_vars: {
key: "V2_STAGING_BUCKET"
value: "gcloud-python-test"
}

# We only upload the image in the main `docs` build.
env_vars: {
key: "TRAMPOLINE_IMAGE_UPLOAD"
value: "false"
}
39 changes: 24 additions & 15 deletions .kokoro/publish-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,16 @@ set -eo pipefail
# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

cd github/python-dlp

# Remove old nox
python3.6 -m pip uninstall --yes --quiet nox-automation
export PATH="${HOME}/.local/bin:${PATH}"

# Install nox
python3.6 -m pip install --upgrade --quiet nox
python3.6 -m nox --version
python3 -m pip install --user --upgrade --quiet nox
python3 -m nox --version

# build docs
nox -s docs

python3 -m pip install gcp-docuploader

# install a json parser
sudo apt-get update
sudo apt-get -y install software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get -y install jq
python3 -m pip install --user gcp-docuploader

# create metadata
python3 -m docuploader create-metadata \
Expand All @@ -52,4 +42,23 @@ python3 -m docuploader create-metadata \
cat docs.metadata

# upload docs
python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket docs-staging
python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}"


# docfx yaml files
nox -s docfx

# create metadata.
python3 -m docuploader create-metadata \
--name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
--version=$(python3 setup.py --version) \
--language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
--distribution-name=$(python3 setup.py --name) \
--product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \
--github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \
--issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json)

cat docs.metadata

# upload docs
python3 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx --staging-bucket "${V2_STAGING_BUCKET}"
34 changes: 34 additions & 0 deletions .kokoro/samples/lint/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "lint"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-dlp/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-dlp/.kokoro/trampoline.sh"
6 changes: 6 additions & 0 deletions .kokoro/samples/lint/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/lint/periodic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/lint/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
Loading