Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

docs: add sample for update transfer config #46

Merged
merged 4 commits into from
Sep 15, 2020

Conversation

HemangChothani
Copy link
Contributor

Fixes #9

@HemangChothani HemangChothani requested review from shollyman and a team as code owners September 14, 2020 12:08
@HemangChothani HemangChothani requested review from leahecole and removed request for a team September 14, 2020 12:08
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 14, 2020
Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine.

I added a few comments, but later realized this was just the existing code being moved. If you think they are out of scope and/or too much work, we can ignore them in this PR.


@pytest.fixture
def project_id():
return os.environ["GOOGLE_CLOUD_PROJECT"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the environment variable is not set, e.g. when running the tests locally?

If a test cannot proceed without this value, it would IMO make sense to raise a more informative exception than KeyError.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this file environment_variables used in samples/nox.py file, so need to handle there, here i can't edit nox.py file.

def get_pytest_env_vars():
"""Returns a dict for pytest invocation."""
ret = {}
# Override the GCLOUD_PROJECT and the alias.
env_key = TEST_CONFIG['gcloud_project_env']
# This should error out if not set.
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for resource_name in doomed:
try:
bqdts_client.delete_transfer_config(resource_name)
except google.api_core.exceptions.NotFound:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other random errors such as a temporary network timeout or something?

If deleting a resource fails, we would still want to proceed and delete the others, especially if the initial error is transient is is less likely to affect other deletion attempts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added else here so all other exception pass here. so every other delete operation will proceed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HemangChothani This extra else has no effect here, since it's executed when no exception is raised.

Did you actually mean the following or do I misunderstand the comment?

for resource_name in doomed:
    try:
        # delete resource...
    except Exception:
        pass  # ignore errors

P.S.: If the coverage check complains, a pragma: NO COVER comment should be also added.

@HemangChothani
Copy link
Contributor Author

@plamut Yes, i will open a separate PR for the comments as don't want to mix-up here.

@plamut
Copy link
Contributor

plamut commented Sep 14, 2020

@HemangChothani That sounds good, thanks.

@product-auto-label product-auto-label bot added api: bigquerydatatransfer Issues related to the googleapis/python-bigquery-datatransfer API. samples Issues that are directly related to samples. labels Sep 15, 2020
@HemangChothani
Copy link
Contributor Author

@plamut Sorry for the noise, but as this branch is didn't merged till now so have push some recommended changes.

@plamut
Copy link
Contributor

plamut commented Sep 15, 2020

@HemangChothani That's OK, please just see the new remark about error catching, thanks!

@plamut plamut merged commit bd01020 into googleapis:master Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: bigquerydatatransfer Issues related to the googleapis/python-bigquery-datatransfer API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please add sample of FieldMask
2 participants