| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| # use absolute path because docker requires absolute path | ||
| # in volume name. | ||
| absolute_library_path = str(Path(library_path).resolve()) | ||
| if absolute_library_path in libraries: |
There was a problem hiding this comment.
We don't need this check because the Generation object is validated when reaches this point.
Sorry, something went wrong.
| library_name = library.get_library_name() | ||
| if library_name in seen_library_names: | ||
| raise ValueError( | ||
| f"{library.name_pretty} has the same library name with " |
There was a problem hiding this comment.
Can we make the error message more verbose and actionable? Something like
f"Both {library.name_pretty} and {seen_library_names.get(library_name)} have the same library_name:
{library_name}, please update one of the library to have a different library_name."
Sorry, something went wrong.
There was a problem hiding this comment.
Another edge case is that two libraries may have the same name_pretty, but I think the error message is already good enough, so we may not have to consider it.
Sorry, something went wrong.
There was a problem hiding this comment.
Done.
Sorry, something went wrong.
| if key not in config: | ||
| raise ValueError(f"required key {key} not found in yaml") | ||
| raise ValueError( | ||
| f"required key {key} not found in {config} " f"when parsing yaml" |
There was a problem hiding this comment.
Is {config} going to print out the whole config? If yes, I don't think we want to do that. Something like
f"Required repo level config {key} not found"
should be good enough.
Sorry, something went wrong.
There was a problem hiding this comment.
Separately, there are a few library level required field, and I don't see any validation for them yet. They can be addressed in a separate PR.
Sorry, something went wrong.
There was a problem hiding this comment.
I remove config in the err message.
Separately, there are a few library level required field, and I don't see any validation for them yet. They can be addressed in a separate PR.
Library level required fields are tests in utilities_unit_tests.py. I moved it to generation_config_unit_test.py.
Sorry, something went wrong.
There was a problem hiding this comment.
I see that library level config is validated in the same way as repo level config now. However, it makes the error message not clear for library level config. e.g. If api-shortname is missing for a specific library, we don't know which library is missing api-shortname from required key {key} not found.
Sorry, something went wrong.
|
How do we plan to use it? I think we can add it to the CI as a required check for every PR, as this should be a very lightweight check. |
Sorry, something went wrong.
Yes, the check should be finished quickly. I tested with generation_config.yaml in google-cloud-java and it finished in 0.3s: (.venv) joewa-macbookpro:sdk-platform-java joewa$ time python library_generation/cli/entry_point.py validate-generation-config --generation-config-path=../google-cloud-java/generation_config.yaml real 0m0.299s user 0m0.161s sys 0m0.052s I added how to use the check in the description. |
Sorry, something went wrong.
There was a problem hiding this comment.
Can the command just be
docker run ... python /src/cli/entry_point.py validate-generation-config
without specifying the yaml location? I think it should be fine since we have a default location?
Sorry, something went wrong.
| # be raised. | ||
| @parameterized.expand( | ||
| [ | ||
| ("libraries", f"{test_config_dir}/config_without_libraries.yaml"), |
There was a problem hiding this comment.
I'm still not a fan of parameterized tests, but I know this test was pre-existing, and in this case, the name of test yamls are kind of self-explanatory, so it's fine.
Sorry, something went wrong.
There was a problem hiding this comment.
I replaced this parameterized test to several individual tests.
Sorry, something went wrong.
| if key not in config: | ||
| raise ValueError(f"required key {key} not found in yaml") | ||
| raise ValueError( | ||
| f"required key {key} not found in {config} " f"when parsing yaml" |
There was a problem hiding this comment.
I see that library level config is validated in the same way as repo level config now. However, it makes the error message not clear for library level config. e.g. If api-shortname is missing for a specific library, we don't know which library is missing api-shortname from required key {key} not found.
Sorry, something went wrong.
Yes, if the yaml location is not specified, the default value is generation_config.yaml in the current working directory. |
Sorry, something went wrong.
I added a parameter, level, so that library config is shown in the raised exception. Missing a repo level parameter will not print the whole config (existing behavior). |
Sorry, something went wrong.
The main concern is not that we don't know if the config is at library or repo level, the concern is that we don't know which library is missing a config if it's a library level config. |
Sorry, something went wrong.
When parsing from yaml, we don't know which parameter maybe missing so I think the best we can do is printing the library dict and hopefully some of the values can let us find which library is missing parameter. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM other than one minor issue for unit test. Separately I think we should error out on unknown parameters, which I don't think we are doing currently.
Sorry, something went wrong.
I'll address this issue in a follow-up PR. |
Sorry, something went wrong.
|
Sorry, something went wrong.
|
Please retry analysis of this Pull-Request directly on SonarCloud |
Sorry, something went wrong.
|
Sorry, something went wrong.
🤖 I have created a release *beep* *boop* --- <details><summary>2.40.0</summary> ## [2.40.0](v2.39.0...v2.40.0) (2024-05-02) ### Features * [common-protos] add `Weight` to common types for Shopping APIs to be used for accounts bundle ([#2699](#2699)) ([5bb9770](5bb9770)) * add a CLI tool to validate generation configuration ([#2691](#2691)) ([f2ce524](f2ce524)) * Parser to consume the api-versioning value from proto ([#2630](#2630)) ([40711fd](40711fd)) * Update Gapic generator and Gax to emit api-versioning via header ([#2671](#2671)) ([e63d1b4](e63d1b4)) ### Bug Fixes * change folder prefix for adding headers ([#2688](#2688)) ([4e92be8](4e92be8)) * Log HttpJson's async thread pool core size ([#2697](#2697)) ([34b4bc3](34b4bc3)) * replace `cfg = "host"` with `cfg = "exec"` ([#2637](#2637)) ([6d673f3](6d673f3)) * Return resolved endpoint from StubSettings' Builder ([#2715](#2715)) ([32c9995](32c9995)) ### Dependencies * Make opentelemetry-api an optional dependency. ([#2681](#2681)) ([3967a19](3967a19)) * update dependency absl-py to v2.1.0 ([#2659](#2659)) ([cae6d79](cae6d79)) * update dependency gitpython to v3.1.43 ([#2656](#2656)) ([208bef4](208bef4)) * update dependency lxml to v5.2.1 ([#2661](#2661)) ([b95ad49](b95ad49)) * update dependency net.bytebuddy:byte-buddy to v1.14.14 ([#2703](#2703)) ([87069bc](87069bc)) * update dependency typing to v3.10.0.0 ([#2663](#2663)) ([7fb5653](7fb5653)) * update gapic-showcase to v0.33.0 ([#2653](#2653)) ([0a71cbf](0a71cbf)) ### Documentation * Add contributing guidelines to PR and issue templates ([#2682](#2682)) ([42526dc](42526dc)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
In this PR: - Add a CLI tool to validate generation config. Downstream libraries, e.g., google-cloud-java, can write a workflow job like: ``` docker run ... python /src/cli/entry_point.py \ validate-generation-config \ --generation-config-path=path/to/generation_config.yaml ```
🤖 I have created a release *beep* *boop* --- <details><summary>2.40.0</summary> ## [2.40.0](v2.39.0...v2.40.0) (2024-05-02) ### Features * [common-protos] add `Weight` to common types for Shopping APIs to be used for accounts bundle ([#2699](#2699)) ([5bb9770](5bb9770)) * add a CLI tool to validate generation configuration ([#2691](#2691)) ([f2ce524](f2ce524)) * Parser to consume the api-versioning value from proto ([#2630](#2630)) ([40711fd](40711fd)) * Update Gapic generator and Gax to emit api-versioning via header ([#2671](#2671)) ([e63d1b4](e63d1b4)) ### Bug Fixes * change folder prefix for adding headers ([#2688](#2688)) ([4e92be8](4e92be8)) * Log HttpJson's async thread pool core size ([#2697](#2697)) ([34b4bc3](34b4bc3)) * replace `cfg = "host"` with `cfg = "exec"` ([#2637](#2637)) ([6d673f3](6d673f3)) * Return resolved endpoint from StubSettings' Builder ([#2715](#2715)) ([32c9995](32c9995)) ### Dependencies * Make opentelemetry-api an optional dependency. ([#2681](#2681)) ([3967a19](3967a19)) * update dependency absl-py to v2.1.0 ([#2659](#2659)) ([cae6d79](cae6d79)) * update dependency gitpython to v3.1.43 ([#2656](#2656)) ([208bef4](208bef4)) * update dependency lxml to v5.2.1 ([#2661](#2661)) ([b95ad49](b95ad49)) * update dependency net.bytebuddy:byte-buddy to v1.14.14 ([#2703](#2703)) ([87069bc](87069bc)) * update dependency typing to v3.10.0.0 ([#2663](#2663)) ([7fb5653](7fb5653)) * update gapic-showcase to v0.33.0 ([#2653](#2653)) ([0a71cbf](0a71cbf)) ### Documentation * Add contributing guidelines to PR and issue templates ([#2682](#2682)) ([42526dc](42526dc)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>2.40.0</summary> ## [2.40.0](googleapis/sdk-platform-java@v2.39.0...v2.40.0) (2024-05-02) ### Features * [common-protos] add `Weight` to common types for Shopping APIs to be used for accounts bundle ([#2699](googleapis/sdk-platform-java#2699)) ([90a28ef](googleapis/sdk-platform-java@90a28ef)) * add a CLI tool to validate generation configuration ([#2691](googleapis/sdk-platform-java#2691)) ([f52f8cc](googleapis/sdk-platform-java@f52f8cc)) * Parser to consume the api-versioning value from proto ([#2630](googleapis/sdk-platform-java#2630)) ([c112b37](googleapis/sdk-platform-java@c112b37)) * Update Gapic generator and Gax to emit api-versioning via header ([#2671](googleapis/sdk-platform-java#2671)) ([cb5ada0](googleapis/sdk-platform-java@cb5ada0)) ### Bug Fixes * change folder prefix for adding headers ([#2688](googleapis/sdk-platform-java#2688)) ([ab5ba1d](googleapis/sdk-platform-java@ab5ba1d)) * Log HttpJson's async thread pool core size ([#2697](googleapis/sdk-platform-java#2697)) ([31038d1](googleapis/sdk-platform-java@31038d1)) * replace `cfg = "host"` with `cfg = "exec"` ([#2637](googleapis/sdk-platform-java#2637)) ([fd12e0f](googleapis/sdk-platform-java@fd12e0f)) * Return resolved endpoint from StubSettings' Builder ([#2715](googleapis/sdk-platform-java#2715)) ([6139a73](googleapis/sdk-platform-java@6139a73)) ### Dependencies * Make opentelemetry-api an optional dependency. ([#2681](googleapis/sdk-platform-java#2681)) ([2239c8c](googleapis/sdk-platform-java@2239c8c)) * update dependency absl-py to v2.1.0 ([#2659](googleapis/sdk-platform-java#2659)) ([b2b7738](googleapis/sdk-platform-java@b2b7738)) * update dependency gitpython to v3.1.43 ([#2656](googleapis/sdk-platform-java#2656)) ([6d273ad](googleapis/sdk-platform-java@6d273ad)) * update dependency lxml to v5.2.1 ([#2661](googleapis/sdk-platform-java#2661)) ([7a34168](googleapis/sdk-platform-java@7a34168)) * update dependency net.bytebuddy:byte-buddy to v1.14.14 ([#2703](googleapis/sdk-platform-java#2703)) ([72b0441](googleapis/sdk-platform-java@72b0441)) * update dependency typing to v3.10.0.0 ([#2663](googleapis/sdk-platform-java#2663)) ([4c64e98](googleapis/sdk-platform-java@4c64e98)) * update gapic-showcase to v0.33.0 ([#2653](googleapis/sdk-platform-java#2653)) ([5c12155](googleapis/sdk-platform-java@5c12155)) ### Documentation * Add contributing guidelines to PR and issue templates ([#2682](googleapis/sdk-platform-java#2682)) ([82f5ce8](googleapis/sdk-platform-java@82f5ce8)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
In this PR:
Downstream libraries, e.g., google-cloud-java, can write a workflow job like: