Repository navigation
Conversation
| cls: EntityUri, | ||
| uri_string: str, | ||
| default_configs: dict | None = None, | ||
| validate_uri: bool = True, |
There was a problem hiding this comment.
Is there any reason that we don't want to validate URI in certain cases?
There was a problem hiding this comment.
the only scenario so far is for the purpose of this PR: validating that we can successfully parse a Rule Binding configs without assuming that we have already parsed the metadata_registry_defaults arguments which contains information required to successfully validate the entity_uris.
To be clear, this flag was added purely for the purpose of this PR. This seemed like a cleaner way to avoid introducing breaking API changes to existing interfaces.
There was a problem hiding this comment.
@nauh PTAL please let me know if there's any further question!
To be clear, I had to add the validate_uri argument to prevent an error with uri validation failing due to the 'default_configs' not being available at this point to be included in the URI instantiation.
The error this fixes in the test_cli_unit test is:
Traceback (most recent call last):
File "/home/thinhha_google_com/.cache/bazel/_bazel_thinhha_google_com/b633505a2816fec546811907bc138b6c/sandbox/linux-sandbox/1/execroot/clouddq/bazel-out/k8-fastbuild/bin/tests/test_cli_unit.runfiles/clouddq/clouddq/classes/dq_configs_cache.py", line 178, in load_all_rule_bindings_collection
dq_rule_binding.DqRuleBinding.from_dict(
File "/home/thinhha_google_com/.cache/bazel/_bazel_thinhha_google_com/b633505a2816fec546811907bc138b6c/sandbox/linux-sandbox/1/execroot/clouddq/bazel-out/k8-fastbuild/bin/tests/test_cli_unit.runfiles/clouddq/clouddq/classes/dq_rule_binding.py", line 79, in from_dict
parsed_entity_uri = EntityUri.from_uri(
File "/home/thinhha_google_com/.cache/bazel/_bazel_thinhha_google_com/b633505a2816fec546811907bc138b6c/sandbox/linux-sandbox/1/execroot/clouddq/bazel-out/k8-fastbuild/bin/tests/test_cli_unit.runfiles/clouddq/clouddq/classes/dq_entity_uri.py", line 86, in from_uri
entity_uri.validate()
File "/home/thinhha_google_com/.cache/bazel/_bazel_thinhha_google_com/b633505a2816fec546811907bc138b6c/sandbox/linux-sandbox/1/execroot/clouddq/bazel-out/k8-fastbuild/bin/tests/test_cli_unit.runfiles/clouddq/clouddq/classes/dq_entity_uri.py", line 112, in validate
self._validate_dataplex_uri_fields(
File "/home/thinhha_google_com/.cache/bazel/_bazel_thinhha_google_com/b633505a2816fec546811907bc138b6c/sandbox/linux-sandbox/1/execroot/clouddq/bazel-out/k8-fastbuild/bin/tests/test_cli_unit.runfiles/clouddq/clouddq/classes/dq_entity_uri.py", line 165, in _validate_dataplex_uri_fields
raise ValueError(
ValueError: Required argument 'projects' not found in entity_uri: dataplex://zones/<my-gcp-dataplex-zone-id>/entities/asset_bucket.
Either add 'projects' to the URI or specify default Dataplex configs for projects/locations/lakes/zones as part of a YAML 'metadata_default_registries' config, e.g.
metadata_registry_defaults:
dataplex:
projects: <my-gcp-project-id>
locations: <my-gcp-dataplex-region-id>
lakes: <my-gcp-dataplex-lake-id>
zones: <my-gcp-dataplex-zone-id>
AmandeepSinghCS
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks !
|
thank you! |
Fixes #156
Error message is now:
To prevent error messages due to rule bindings entity_uris validation failing due to missing default arguments from metadata registry defaults (which would lead to a circular dependency), I've added a
validate_uriflag to the entity_urisfrom_dictmethod which isTrueby default and set toFalseonly for the purpose of this initial validation.I also updated type annotations in
clouddq/lib.pyto the consistent with everywhere else.