-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: resource tags in dataset #2090
base: main
Are you sure you want to change the base?
feat: resource tags in dataset #2090
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.
Thank you so much for adding resource tags in dataset! The PR looks great overall, I just made some minor modifications. I wonder if you could add a system test, as well as a unit test for setter with None? Please let us know if you need any help. Happy holidays!
Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com>
Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com>
Hi @Linchin, thanks for the review. I added system tests in system/test_clients.py I fixed unittests for None, and added more tests for invalid values. See test_resource_tags_setter_bad_value. Merry Christmas and happy new year! |
@@ -278,33 +286,72 @@ def test_create_dataset_with_default_rounding_mode(self): | |||
self.assertTrue(_dataset_exists(dataset)) | |||
self.assertEqual(dataset.default_rounding_mode, "ROUND_HALF_EVEN") | |||
|
|||
def _create_resource_tag_key_and_values(self, key, values): |
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.
Got inspired from this implementation. Just took out this method to be used in both dataset & test implementation.
Do you have any tips on how to run system test locally, @Linchin? There is some setup to the actual project required, but this explanation is too vague to follow.
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.
In general you can just use pytest to run system tests, it's slightly easier than nox, and should be able to run on any python version:
pytest tests/system/test_client.py
You can specify the test class or method too:
pytest tests/system/test_client.py::TestBigQuery::test_update_dataset
This should make it faster.
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 you also need to run lint, that will need to use nox:
nox -r -s lint
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.
Thanks I ran linting locally.
I still could not run system tests locally still. I think I need to specify GOOGLE_APPLICATION_CREDENTIALS
env var (see here) anyway, but not sure what credentials I can use.
I tried to use the credentials of a service account in my personal Google Cloud project, which has a owner
role in this project, but I got all PERMISSION_DENIED
errors for dataset creation, table creation etc.
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 if you run pytest instead of nox, you don't have to have GOOGLE_APPLICATION_CREDENTIALS
set up, because we are bypassing noxfile.py
.
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.
Ok I managed running system test locally. This is how:
- Make a python script,
install_dependencies.py
parsing all dependencies in specifiednoxfile.py
, to install dependencies in my local pip. - For some reason,
google-cloud-testutils
was not installed in this manner, as specified here, so install this one manually. - Configure
gcloud auth
to my personal GCP project - Run pytest
tests/system/test_client.py
Outdated
) | ||
try: | ||
tag_key = tag_key_client.create_tag_key(tag_key=new_tag_key).result() | ||
except AlreadyExists: # When system tests runs in parallel for multiple Python versions, the tag key may already exist |
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.
Since we run multiple system tests at the same time for different Python versions, we got AlreadyExists
error. We got this error only in 3.12 test, but not in 3.8 test (Does not matter on which Python version, but whatever comes later I assume).
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.
Great, thank you for fixing this!
Fixes #2091 🦕