Skip to content

Commit

Permalink
fix: do not set job timeout extra property if None
Browse files Browse the repository at this point in the history
chore(python): fix docs build (#1984)

Source-Link: googleapis/synthtool@bef813d
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:94bb690db96e6242b2567a4860a94d48fa48696d092e51b0884a1a2c0a79a407

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
bmwant and gcf-owl-bot[bot] committed Aug 12, 2024
1 parent 4383cfe commit b30ca9f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:52210e0e0559f5ea8c52be148b33504022e1faef4e95fbe4b32d68022af2fa7e
digest: sha256:94bb690db96e6242b2567a4860a94d48fa48696d092e51b0884a1a2c0a79a407
# created: 2024-07-31T14:52:44.926548819Z
9 changes: 4 additions & 5 deletions .kokoro/docker/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,18 @@ RUN tar -xvf Python-3.10.14.tgz
RUN ./Python-3.10.14/configure --enable-optimizations
RUN make altinstall

RUN python3.10 -m venv /venv
ENV PATH /venv/bin:$PATH
ENV PATH /usr/local/bin/python3.10:$PATH

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

# Test pip
RUN python3 -m pip
RUN python3.10 -m pip

# Install build requirements
COPY requirements.txt /requirements.txt
RUN python3 -m pip install --require-hashes -r requirements.txt
RUN python3.10 -m pip install --require-hashes -r requirements.txt

CMD ["python3.10"]
20 changes: 10 additions & 10 deletions .kokoro/publish-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@ export PYTHONUNBUFFERED=1
export PATH="${HOME}/.local/bin:${PATH}"

# Install nox
python3 -m pip install --require-hashes -r .kokoro/requirements.txt
python3 -m nox --version
python3.10 -m pip install --require-hashes -r .kokoro/requirements.txt
python3.10 -m nox --version

# build docs
nox -s docs

# create metadata
python3 -m docuploader create-metadata \
python3.10 -m docuploader create-metadata \
--name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
--version=$(python3 setup.py --version) \
--version=$(python3.10 setup.py --version) \
--language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
--distribution-name=$(python3 setup.py --name) \
--distribution-name=$(python3.10 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 --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}"
python3.10 -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 \
python3.10 -m docuploader create-metadata \
--name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
--version=$(python3 setup.py --version) \
--version=$(python3.10 setup.py --version) \
--language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
--distribution-name=$(python3 setup.py --name) \
--distribution-name=$(python3.10 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}"
python3.10 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx --staging-bucket "${V2_STAGING_BUCKET}"
7 changes: 5 additions & 2 deletions google/cloud/bigquery/job/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ def job_timeout_ms(self, value):
err.__traceback__
)

""" Docs indicate a string is expected by the API """
self._properties["jobTimeoutMs"] = str(value)
if value is not None:
# docs indicate a string is expected by the API
self._properties["jobTimeoutMs"] = str(value)
else:
self._properties.pop("jobTimeoutMs", None)

@property
def labels(self):
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/job/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,3 +1320,21 @@ def test_job_timeout_ms(self):
# Confirm that integers get converted to strings.
job_config.job_timeout_ms = 5000
assert job_config.job_timeout_ms == "5000" # int is converted to string

def test_job_timeout_is_none_when_set_none(self):
job_config = self._make_one()
job_config.job_timeout_ms = None
# Confirm value is None and not literal string 'None'
assert job_config.job_timeout_ms is None

def test_job_timeout_properties(self):
# Make sure any value stored in properties is erased
# when setting job_timeout to None.
job_config = self._make_one()
job_config.job_timeout_ms = 4200
assert job_config.job_timeout_ms == "4200"
assert job_config._properties.get("jobTimeoutMs") == "4200"

job_config.job_timeout_ms = None
assert job_config.job_timeout_ms is None
assert "jobTimeoutMs" not in job_config._properties

0 comments on commit b30ca9f

Please sign in to comment.