-
Notifications
You must be signed in to change notification settings - Fork 29
docs: add sample for update transfer config #46
docs: add sample for update transfer config #46
Conversation
There was a problem hiding this 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"] |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
python-bigquery-datatransfer/samples/noxfile.py
Lines 67 to 74 in 3c16677
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the file where we need to change the template format: https://github.com/googleapis/synthtool/blob/master/synthtool/gcp/templates/python_samples/noxfile.py.j2
samples/tests/conftest.py
Outdated
for resource_name in doomed: | ||
try: | ||
bqdts_client.delete_transfer_config(resource_name) | ||
except google.api_core.exceptions.NotFound: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@plamut Yes, i will open a separate PR for the comments as don't want to mix-up here. |
@HemangChothani That sounds good, thanks. |
…y-datatransfer into bigquery_datatransfer_issue_9
@plamut Sorry for the noise, but as this branch is didn't merged till now so have push some recommended changes. |
@HemangChothani That's OK, please just see the new remark about error catching, thanks! |
Fixes #9